Initial internationalization support in weber

Today i added initial internationalization support to the Weber and in this post i'll try to show how it works. For internationalization we have t helper from Weber.I18n module. Let's create new project with weber.new and configure route:

It will be simple web application with two endpoints: / - for the main page and /:lang for the changing language. We will have only one simple html template in the our application, it will be html page with two links En/De for english and german languages:

Here you can see 2 links and two t helper calls. Principe of works t t helper is very simple, it gets locale of current user and tries to find translation for given key. Now we must create language files in lang directory. Language file it is just json file with name like en_US or de_DE, it's structure can be like this:

And in the end of all, let's create controller with 2 actions, first action will be for main page rendering and second action will be for language changing:

First action - action - is very simple and it just render main page with 2 links. Second action - change_locale - gets language from URL, updates locale for current user and updates the main page. That's all very simple. Internationalization support in very early stage in Weber, if you find a bugs or you will have questions/suggestions, please write us to the issues

Comments