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.

Locale file in theme directory

edited December 2010 in Vanilla 2.0 - 2.8
I've seen a number of references in these forums to changing text strings (such as "Howdy stranger") by editing /conf/locale.php. This works fine but, as I just discovered, Vanilla updates will destroy any changes you make here unless you remember to manually remove the default locale.php file first. The config file in this directory is safe because Vanilla distributes config-defaults.php but also reads config.php, where your changes are supposed to go. Not so for the locales file.

Upon investigation, I've found reference to another localization file that can optionally exist in /themes/theme-name/locale/ but no information on how this file should be named. This comment uses /themes/CURRENT_THEME_NAME/locale/LANG.php to indicate this file, but what should LANG be? "en"? "en-US"? Something else? I've tried a number of things here but my change are not reflected in the UI the way they are when I use the file in /conf.

I can't find this information in the Vanilla documentation, but the docs are not searchable so I may be missing something.

What is the correct and upgrade-safe way to add these translations?



  • Options
    msikmamsikma New
    edited December 2010
    Hi there,

    I couldn't find any documentation on this either so I went and checked the responsible library files.

    It seems that:
    • The code only checks for the existence of /themes/CURRENT_THEME_NAME/locale/LANG.php. Other files are ignored.
    • Presumably only standard RFC 1766 locale names are accepted. The default is en-CA. German would be de_DE, Dutch nl_NL. You should be able to easily find a list of possible values somewhere on Google.
    • In order for the changes to take effect, you must delete the /cache/locale_map.ini file!
    If the cache file exists, it will not even check if there are new files to be used.
  • Options
    edited December 2010
    Thanks, I was tripped up in two places. First, I didn't know about the locale cache file; second, I found that the locale is hard-coded to en-CA in /conf/config-defaults.php.

    So to fix my problem, I:

    1. Added this line to /conf/config.php:

    $Configuration['Garden']['Locale'] = 'en-US';

    2. Added my translation strings to /themes/THEME_NAME/locale/en-US.php

    3. Deleted /cache/locale_map.ini and reloaded the page.

    Now it works as expected and I don't need to worry about updates overwriting my translations. Thanks again.

Sign In or Register to comment.