HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Localization

ddumontddumont ✭✭
@Todd I reported a bug about localization earlier today, turned out to be my mistake... but it does raise a few issues about current localization in Vanilla.

Here's what I'm trying to do:
I am building some integration of my Android app into my forum. Part of this involves plugins to extend the user profile and a theme with some minor tweaks to the default theme.

Now I am noticing that a few string resources are not quite right. I would rather not have my changes overridden on upgrade so I went about this by making a new locale. The only problem is locales in Vanilla do not behave the way they do in most places I've used them.

I looked around for an analog to the resource bundles we have in java and found this:
http://php.net/manual/en/class.resourcebundle.php

The way I expected things to work was that you guys would provide a default resource bundle. Then based on user settings or browser language, you would build a resource bundle for the locale. http://userguide.icu-project.org/locale/resources has some good info on how they work.

So without any extra resources, just providing default strings (virgin install of vanilla) a ResourceBundle for 'pt_BR' would still serve all of the default strings.

I've not fully investigated the i18n implementation in Vanilla, but I was kinda confused when starting to build my locale. I wasn't expecting to need to create a locale for each supported language... and then name and version it. I expected it to behave more like a resource bundle.

I also tried overriding the text for the TOS link in the signup page by just using my plugin, and it didn't work out so well...
Can you guys comment on the implementation of the locales in Vanilla and if you might consider moving to the ResourceBundle model I linked?

How would you suggest I safely override certain translatable strings without having to create my own locale (which would seemingly involve me having to copy the existing one as a starting point)?
I'd rather not have to do that, as I'd like to continue to get changes from you through upgrades while changing certain resources to fit my forum better.

There was an error rendering this rich post.

Comments

  • ToddTodd Chief Product Officer Vanilla Staff
    This is something that could be better. What I recommend doing is this:

    1. Put your translations into a locale pack.
    2. If you are writing in English then leave the locale of your locale pack as 'en-CA'.
    3. When you enable your locale pack all of the default translations will be loaded first and then yours will override them.

    You can read more about localization here.
  • Ahh ok. So if I provide the same locale as the default defined locale, then my changes will be overrides rather than replacing the existing locale?

    I did read that link, what I'm concerned about is that I have translations for my app in Portuguese, German, French, and a few others. The locale system here looks like I'll have to include 4 or so different locales (and fully translate vanilla for the non en-CA ones).

    Will those 4-5 locales, once activiated on the forum, key off of the accept language of the user's browser?

    There was an error rendering this rich post.

  • Also, what are the rules behind what plugins can contribute to the locale?

    There was an error rendering this rich post.

Sign In or Register to comment.