cakephp 3.x
I was surprised that my sites html pages language was :
html lang=“en”
Although ‘defaultLocale’ is set to :
env(‘APP_DEFAULT_LOCALE’, ‘fr_FR’)
Can it be considered some type of oversight or did I miss something ?
So, your layout just has “<html>” in it? Are you looking at the results with “view source” (or, equivalently, some command line tool like GET or wget or curl), or with developer tools?
Ok, well, CakePHP doesn’t alter/change the html unless you specifically have code for it (i.e. an echo). So, it must be your browser, network or server that’s adding it.
Pretty much
Or build a little Html helper that you can call that outputs it for you (so you can change it based on the language of the user if applicable as well)
I believe so. The naming standard should mean that your language code is either xx or xx_YY. In either case, the first two characters would be what you want.
Alternatively what one could do (but I haven’t tested this yet) is get the locale in the AppController, substr it there and pass it to the template view.
This would minimize the PHP code needed in the template.