Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor localization / i18n libs comparison

I'm trying to evaluate which one to use so would appreciate any feedback from others who made this decision. It seems there are two big projects for translation:

MessageFormat

http://messageformat.meteor.com/

PROS

  • based on MessageFormat.js substantial lib
  • includes extraction tool
  • handles fuzzy strings and versions, if strings are updated in the app
  • javascript and handlebars methods
  • prebuilt translation tool / webUI for string translations http://messageformat.meteor.com/translate/af
  • written by Gadi, meteor guru active community guy

TAP i18n

https://github.com/TAPevents/

notes:

  • based on i18next engine
  • uses AJAX to load languages

PROS

  • helpers for bootstrap/language pickers
  • support for packages
  • support for DB collection translation https://github.com/TAPevents/tap-i18n-db)

CONS? - only JSON format, no yaml, so tedious to edit - no webUI for managing strings

There are some other projects such as https://github.com/Nemo64/meteor-translator but the two above seem the most thorough. Have I missed any others?

What other criteria have people use when selecting the right tool? The underlying tech of messageFormat vs. i18next seems a factor.

Questions:

1) Multiple languages in page

I'm trying to do a bilingual app but:

Tap: "Only the required translations for the current client's language are sent over the wire"

does this mean the language can only be A or B, but not a mixture, switched automagically based on a session?

ie how to provide helpers in a page to have multiple translation

  EN: {{tr "string", 'en'}}
  FR: {{tr "string", 'fr'}}

2) Extracting dynamic data

At least messageFormat project will capture/extract strings in static pages, but if I have a lot of content already in complex mongo collections, is there a way to capture this?

Thanks for any insight from the package creators or others in this area.

like image 850
dcsan Avatar asked Oct 20 '22 01:10

dcsan


1 Answers

It sounds like you've already made up your mind. ;)

how to provide helpers in a page to have multiple translation

In MessageFormat you don't need to have special helpers for each language. You simply define your key and value once in your template for your 'base' language--let's say English. Then later you can use the MessageFormat web-based translation tool to add additional strings for say French, Spanish, etc.

To select the language, you simple set locale, so you can add a drop-down in your client so this can be done by your user.

See SetLocale: http://messageformat.meteor.com/docs#methods

if I have a lot of content already in complex mongo collections, is there a way to capture this?

I'd really need to know much more detail about the your application to answer how you might be able to do that. MessageFormat just creates a messageformat.js file of functions, so you could maybe directly modify that file, but they it would get overwritten the next time you run mf_extract. So I think you really just need to get the name-value pairs defined in your app i.e. {{mf 'admin.dashboard.title' 'Dashboard'}}. But then if you have some way to map your current 'content' to these my keys, you might be able to load that content into the mfstrings collection, or maybe write code to pull them into mfAll.js . . .

We are using MessageFormat for all our Meteor apps and love it. I don't have experience with TAP i18n, but MessageFormat seems to serve our needs well (we are doing Japanese, English, Chinese).

I suggest just adding it to your project, or using it with a test project to get some experience with it, then you can decision how you like it. Just make sure your read about mf_extract or you'll get stuck.

like image 171
Max Hodges Avatar answered Oct 24 '22 00:10

Max Hodges