Rails SDK has the following mechanism for choosing which locale to use:
- The first thing it does is looking for the "current_locale" method defined in the ApplicationController. If such method is defined and is returning a non nil value, that locale value will be used in the SDK. You need to make sure that the locale that this method passes back is one of the locales configured with your project, to ensure consistency.
- If "current_locale" is not defined, then the SDK will look at a "locale" parameter (params[:locale]) to see if user has explicitly requested a specific locale. If the param is available and the locale is supported by the application, then the locale will be stored in a cookie and will be used.
- If locale parameter has not been passed, the SDK checks if there is a locale value in the user cookie. If it exists and is supported by your project, the locale will be used.
- Finally, if non of the above approaches have produced a usable locale, the SDK will look into the accept-language header and find the first available locale in the header that intersects your project locales. If such locale exists, then it will be used.
- In all other cases your default project locale will be used.
If you are interested to review the code that does all of the above, please visit the following URL: