Translator using container locale parameter instead of the session locale - internationalization

I have defined my routing using the special _locale parameter. When a route is matched by the router, the locale is correctly set in my user session and I can see the correct locale being used in the profiler.
$this->get('session')->getLocale(); // Return the correct locale
The problem is that the i18n translator is always using the default locale defined in my parameters.yml file instead of using the locale set in the session.
Is there something i'm missing ? Do I have to manually pass the session locale to the translator ?
I'm using Symfony 2.0.9.

According to this link: Translations configuration, "The locale used in translations is the one stored in the user session.". If it's not the case for you, I guess you changed something in your configuration?
By the way, the locale will be stored in the request and not in the session anymore in 2.1: https://github.com/symfony/symfony/commit/74bc699b270122b70b1de6ece47c726f5df8bd41

Related

Laravel mcamara/laravel-localization package overrides config('app.locale')

I'm trying "mcamara/laravel-localization" package to localize my app and it works as expected except for one small issue, the package seems to override the config('app.locale') default value.
For instance if the default value of the locale property in config\app.php file is set to en end I changed the application language to french with the language switcher then config('app.locale') is evaluated to fr instead of the default en.
I hope the issue is clear so my question is: how can get the default locale as defined the config\app.php config file?
Thanks
whole point of that package is changing locale, no matter what the default locale is that package change it to whatever you config it to.
but you can get current locale anytime you want using currentLocale() method of App facade and change it with setLocale($yourLocale).
In order to get the current language code, write the following function:
app()->getLocale();
In order to activate the activation of a new language, you can write the following function:
app()->setLocale('fr');

Can geoserver (2.20.0 with i18n) ignore an invalid language parameter in capabilities request and respond with the default language?

I am using geoserver 2.20.0 to provide wms.
I use the i18n internationalization for the wms configuration. I have also set an i18n entry with empty language for each configurable field, acting as the default translation.
Geoserver uses the default values of the title and abstract of the service, when no language parameter is used in the request.
But when I send a getcapabilities request with invalid or not supported language parameter, instead of getting the default values of title and abstract, I get an exception.
Is there a way to fix this and make geoserver respond with the default values?

SailsJS i18n module not changing lang file even the locale was changed

I debugging a SailsJS app, if I print the sails global variables it has the right values for locales, and defaultLocale, etc...
I changing the locale with Accept-Language header in PostMan and works like a charm.
Even it has the right locales, i18n module is taking always the default language translation file. Does someone know what could be happening?
Regards
I suppose it was due my local environment locales config(Ubuntu 18.10), given when I deployed to the VPS it worked like a charm.
Thanks anyway ;)

CouchDB Finnish/Swedish collation view

How can I change a CouchDB view collation to sort skandinavian letters (åäö) after z?
You can't configure it unfortunately. The collation for CouchDB is implemented via the ICU library which does have the facility to provide alternative collations, both from a locale DB and totally custom rules.
Unfortunately CouchDB does not expose any of that, its ucol_open call has a hardcoded "" value for the locale.
As it stands, in order to customize this for your locale, you would need to recompile CouchDB passing a value for that locale parameter to ucol_open, more info on the format etc of that is available here.

Getting request attributes in freemarker

How do I check a value from the request attribute in freemarker?
I tried <#if *${RequestParameters['servicesettings']} ??> but getting errors ->
Encountered "*" at line
Can anyone help?
It depends on the Web application framework, because FreeMarker itself doesn't expose the request parameters. (Well, except if the framework uses freemareker.ext.servlet.FreemarkerServlet which is kind of an extension to FreeMarker.) Also, usually you shouldn't access request parameters directly from an MVC template, or anything that is HTTP/Servlet specific.
As of the error message, what you have written has a few syntax errors... probably you meant <#if RequestParameters.servicesettings??> (it's not JSP - don't use ${...}-s inside FreeMarker tags). This will require that you have RequestParameters in the data-model, that I can't know for sure...
We should write like this:
${Request.requestattribute}
You can use
${requestParameters.servicesettings}.
According to the JavaDoc of the FreemarkerServlet:
It makes all request, request parameters, session, and servlet context attributes available to templates through Request, RequestParameters, Session, and Application variables.
The scope variables are also available via automatic scope discovery. That is, writing Application.attrName, Session.attrName, Request.attrName is not mandatory; it's enough to write attrName, and if no such variable was created in the template, it will search the variable in Request, and then in Session, and finally in Application.
You can simply write:
${attrName}
to get the value of a request attribute (that you might have set in a servlet request filter using request.setAttribute('attrName', 'value')
Worked for me with Freemarker 2.3.27-incubating

Resources