Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Bilingual forum: special cases problems

edited September 2006 in Vanilla 1.0 Help
Hi folks,

I'm currently working on a bilingual forum using Language Selector. it works fine, but there are several things which aren't in the definition.php files, and I wonder how to include them.

- How could I translate the Discussion Labels? They're specified in conf/settings.php and I don't see how to change them for two different languages.
- How could I translate the date and the months' names? From what I understand it comes from a specific PHP function and there's no file in Vanilla allowing to change it, am I wrong?
«1

Comments

  • Date formats are specified in the translation files, specifically in OldPostDateFormatCode. The default value is M jS Y, which will come out as Aug 28th 2006 (for instance). You can change the parameter value, and you can check the documentation of the PHP date function for which values are allowed. For the translation I did (Swedish), I changed it to j M Y which outputs something like 2006 08 28.

    Apparently there is a way to change the names of months, but it involves a bit of tinkering with PHP code, using setlocale() and strftime(). I have never done anything with those functions, but I guess in theory you could change the Vanilla code.
  • Hey, that's clever to set it for displaying only numbers. That's a cool trick, thanks for the idea :) However I still have to find something for the labels translation problem. I tried replacing them with icons like in this thread, but I wasn't really happy with the result.
  • Max_BMax_B New
    edited September 2006
    For the label translation see this post, specifically the #2 item at the end.
    In short: overload the label definition in you language definitions.php file.//labels, see settings $Configuration['TEXT_WHISPERED'] = 'chuchoté'; $Configuration['TEXT_STICKY'] = 'affiché'; $Configuration['TEXT_CLOSED'] = 'fermé'; $Configuration['TEXT_HIDDEN'] = 'masqué'; $Configuration['TEXT_SINK'] = 'coulé'; $Configuration['TEXT_BOOKMARKED'] = 'signet';
  • MarkMark Vanilla Staff
    I'm going to be changing those labels so they are included in the dictionary for 1.0.2.
  • edited September 2006
    Oh it's as simple as that? Thanks for the tip. (Max_B, I think your link points to the current discussion)

    About translation in general, I stumbled upon another problem : most extensions don't include everything. For some of them the title in the settings tab is missing, others lack a couple of words not always seen (for example, "guest" in the Who's Online extension)... It's not a real problem for me because I was still able to add these definitions after digging a bit and modifying the extensions. However, I'd like to share my work with the community: I've translated to french a dozen of extensions, but some of my custom definitions won't work because they aren't included by default in these extensions.

    So, do you think I should upload the modified extensions, knowing I suck at PHP and may have changed something wrong while adding new definitions, or upload only the dictionary part, knowing some definitions won't work unless people modify their extensions by themselves?
  • I'd suggest you contact the extension authors pointing out their oversights and offer your updated code as a replacement.
  • You're right, it's probably the best thing to do.
  • Corrected a typo in the link to VanillaDev
  • With using "$Context->SetDefinition('code', 'definition');" to set a definiton in an extension, the translation can be put in the language definition. So you should also send the translation to the french language package maintainer.
  • Thanks Max_B, now I see how to manage this. Dinoboff, yep, I need to contact Ghotcom. I've corrected many little things in the french package and changed several words and expressions, mostly to gain some space, so it's not only about extensions but also lots of other details. I'll try to set the various still missing definitions I encountered with this syntax, until now I was mostly replacing what I needed by "$Context->GetDefinition('definition');".
  • edited September 2006
    nevermind, i thought you add sometime to create new definitions in some extensions.

    $Context->SetDefinition('code', 'definition')
    should be used instead of
    $Context->Dictionary['code'] = 'definition';
  • Ok, until now I was adding "$Context->GetDefinition('definition');" in the default.php file where I needed to define something, and "$Context->Dictionary['code'] = 'definition';" in the language file.
  • use $Context->SetDefinition('code', 'definition') to set a default definition that will be set only if havn't been set in language/MYLANGUAGE/definitions.php or conf/language.php.
    You still can use $Context->Dictionary['code'] = 'definition'; in definition.php.

    When you translate an extension, what you can :
    - Translate the definitons and put them in conf/language.php (or in your case in definitions.php);
    - If the extension use "$Context->Dictionary['code'] = 'definition';",
    Transform them into $Context->SetDefinition('code', 'definition') or delete them
    And ask the author set SetDefinition in the next release of his extension
    - Ask the maintainer of the language to add your translation.
  • Thanks for the help, I'll do that :)
  • I've just ran into another problem: is there a way to translate roles? I can't find where they are stored.
  • the name of a role you mean? they are in the database I think.
  • Yes, the name of a role. My users are supposed to switch from english to french or from french to english if they need to, so I'd like to translate roles too (call me a annoying perfectionist...). Looks like there's no way to do that if the names are in the database.
  • Replace in the themes/account_profile.php
    <p>'.$this->User->Role.'</p>
    by
    <p>'.$this->Context->GetDefinition($this->User->Role).'</p>
    And create the definitions for your role in definitions.php
  • edited September 2006
    Thanks Dinoboff, it works great :)
    However the translation isn't displayed in the user search results. I've looked for something similar to change in themes/search_results_users.php and I suppose it has something to do with the end of this line:

    <a href="'.GetUrl($this->Context->Configuration, 'account.php', '', 'u', $u->UserID).'">'.$u->Name.'</a> ('.$u->Role.')'

    Problem is I know nothing in PHP syntax, so I don't know what to change.
  • just replace $u->Role by $this->Context->GetDefinition($u->Role)
This discussion has been closed.