Rails i18n: How to know what is the current language?

Ruby on-Rails-3Internationalization

Ruby on-Rails-3 Problem Overview


I am aware of how i18n/l10n is usually done in Rails3, and I chose to have a single ERB file that calls t(...) for localization. But for a particular part I need something special:

I need to display a string whose localization is coming from an external database.

So how can I know the current language, to call the external database with an en or ja parameter?

Something like $LANG in UNIX. Preferably accessible from view or controller.

Ruby on-Rails-3 Solutions


Solution 1 - Ruby on-Rails-3

I18n.locale # Get and set the current locale

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNicolas RaoulView Question on Stackoverflow
Solution 1 - Ruby on-Rails-3Vadim GolubView Answer on Stackoverflow