1
votes

I'm developping a website to train students for programming contest. Right now the website is mostly in french but it's going to be translated in spanish (one other country wants to use our training website).

Internationalisation of the interface is easy but the 1500+ exercices will not all be translated before a long time.

What I need is a way to localize the content (and the interface) in the language choosen by the users but if that specific translation is not available in that language then one should use the default one (french). We would even want to generalize that : imagine that some french exercises are translated in english, your are a spanish person and don't speak french. You first want the spanish version, then the english one and then the french one.

Is there a good way to use internationalization in this case ?

I can try one language and if there isn't any result try an other one but it wouldn't be very efficient....

1

1 Answers

1
votes

For template content, if you're using the Symfony i18n behaviour, the fall-back default language will be automatically available. Whatever you put inside the the __('string') helper will use the default culture (declared in settings.yml) if a translated string is not found. For multi-language database content, you'll either need to use the Symfony i18n table behaviour or build this yourself. I don't know how the Symfony i18n database handling works in the case of a default language if content in a specific language is not found. The queries can get complex. My general opinion is that you'll be better off building the database-related functionality yourself, but that's just me.

For ordering the the languages (first translations, then English, then default), my understanding is that the out-of-the-box Symfony i18n behaviour does NOT support this. You might be able to hack some type of solution by ensuring that in your Spanish XML/XLIFF file, you put English translations inside the <target> tags where the English (but not Spanish) translations are available. This will give you ES -> EN -> FR. However, I would also recommend that you aim to "manage" your translations cleanly so that it doesn't become too complicated/confusing.

Hope that helps.