Best Practice for International Views


#1

antl.formatmessage() is great when you have a few words or sentences, but sometimes you want to localize an entire view. With emails for example.

I could create locale folders inside the view folder, then just change the locale in the controller when I call the view.

views/locales/en/emails/welcome.edge
views/locales/fr/emails/welcome.edge
views/locales/ru/emails/welcome.edge

Is this the best way?


#2

Yes that seems like a reasonable way to do it. Going forward, I will look into better ways to make stuff like this work out of the box.


#3

That would be cool.

Today, I’m working on a way to translate a simple string, not messages. Doing something like you see in many PHP frameworks

__('username')

Just a wrapper for

Antl.formatmessage('app.username')

If translations aren’t on, it just returns the phrase as is.

Another Ex:

__('Please enter a valid email')

Gonna have in in my view globals.