Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to use language file?

In our controllers we are making using of translations functions like t('HomeTitle') and defined its respective transaltion in "locale/en.php" with $Definition['HomeTitle'] = 'My HomePage';

But it is not taking it up. Kindly suggest.


  • R_JR_J Ex-Fanboy Munich Admin

    In your addon/theme make sure you have a 'HasLocale' => true,/ "hasLocale": true, in the info array/addon.json (although I'm not sure it is really needed)
    Afterwards clear /cache/addon.php or /cache/theme/YourTheme.php

    I do not know another reason why it shouldn't be working then.

  • thanks for your comments R_J.

    I have done the things suggested by you. i.e added the "hasLocale": true in addon.json and cleared the cache.

    But still it is not working.

  • Any updates here?

    Has anyone used locale feature?

  • R_JR_J Ex-Fanboy Munich Admin

    Multiple times without any problems.

    Please don't get me wrong, but how exactly does your en.php look like?

    $Definition['HomeTitle'] = 'My HomePage';


    $Definition['HomeTitle'] = 'My HomePage';
  • yes the <?php one.

  • R_JR_J Ex-Fanboy Munich Admin

    I just tested it with a plugin, added a language file, deleted /cache/addon.php and it was displayed correctly.

  • We are using an addon of application type and trying using the locale there.

  • I think if you are using an app to override another apps locale, then obviously there is a question of priority, the framework has to know which app take priority and load in that order, especially if you are using the same locale codes.

    That is kind of why there is a root locale folder.

    grep is your friend.

  • R_JR_J Ex-Fanboy Munich Admin

    If you are defining a locale and it is not working than there could be no interference with other addons.
    But just to make sure, edit your /cache/addons.php, search for your addon and change its "priority" line to 'priority' => 1000,. That will make it run after all other plugins and therefore overwrite all their translations.

    If you are editing the cache/addons.php, search for this part in the array of your plugin:

         'translations' =>
        array (
          'en' =>
          array (
            0 => '/locale/en.php',
    1. Check if translations are a problem or this translation by using another term, most probably not part of Vanilla (some nonsense word)
    2. Check if the word that troubles you is in /conf/locale.php which would override all other translations
    3. Check if you have other problems with the translation function by using it with a "known" translation like e.g. t('ValidateUsername')

    One of all this must help...

Sign In or Register to comment.