Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

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.

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    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 Cheerleader & Troubleshooter Munich Moderator

    Multiple times without any problems.

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

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

    or

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

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    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 Cheerleader & Troubleshooter Munich Moderator

    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.