|
TABLE OF CONTENTS In-code stringsThe strings hard-coded into PHP should be wrapped in CRM/Contact/Form/Search.php ...should be changed like this: CRM/Contact/Form/Search.php This will send the " - any group - " string to our localisation engine, which will in turn call Gettext and return the proper translation (or the string itself, if there's no translation available in the currently-used locale). Sometimes you might need to pass a variable to localisable string. Consider situation like this: Of course yoy can tag both strings separately, but in order to make translation easier (you are keeping the whole context of the sentence), you should pass the variable as an argument to ts() function. Second argument is an array containing numbered values. So the ts() function call should look like this: Note that the array values should themselves be translated by your code before passing in, if appropriate. Respectively, if you want to pass more variables, you just add new elements to the array: In-template stringsThe strings hard-coded into templates should be wrapped in { templates/CRM/Contact/Form/Search/BasicCriteria.tpl ...should be changed like this: templates/CRM/Contact/Form/Search/BasicCriteria.tpl Currenty we're simply passing the contents and arguments of the { If you need to pass a variable to the localisable string, you should use the following pattern: Consistently, every replaceable variable should be named with number and called as %number in the string, like: The span of the { The HTML inside the { The Plurals Issue - number-based strings conjugationThere are situations when we want not only to pass a number to a string, but also make it different based on the number in question; example: "Found 1 contact" / "Found 2 contacts". In English this is easy, there are two plural forms ("contact" vs. "contacts"), but in Polish this is quite different - we say "Znaleziono 1 kontakt", "Znaleziono 2, 3, 4 kontakty", "Znaleziono 5, 6, ..., 10, 11, 12, 13, ... 20, 21 kontaktów", "Znaleziono 22, 23, 24 kontakty", "Znaleziono 25, ..., 101 kontaktów", etc. Gettext handles this perfectly, but has to be told what the count is, and what are the basic singular and plural English strings. This is realised by the PHP exapmple Smarty example
Good practicesAvoid splitted stringsDue to language differences, sometimes certain template tricks should be avoided. E.g. when you have this kind of construct, you cannot properly internationalise it. When you tag New word separately, string extractor will add this word to strings bundle. This means, there will be only one translation of this word available. However, depending on the context, this word can be translated in many ways, e.g. in Polish, it can be "Nowy", "Nowa" or "Nowe". So in order to avoid such situations, please try to use following constructs: Another example would be the tagging of such construct: templates/CRM/Contact/Page/View/Contact.tpl This should be rewritten, as the final tagging looks like this: templates/CRM/Contact/Page/View/Contact.tpl Check what's exactly being taggedExample: CRM/Contact/Form/Individual.php The first Popular errorsExamples: Wrong ...should be: Right The general rules for avoiding erros may be summed up like this:
To check for errors in the from the main CiviCRM directory. You can also check particular files with the PHP extractor: Why don't we use Drupal's
|
Internationalisation guide
Labels
