labels
labels copied to clipboard
4 / 5 letter language codes
Hi there. The docs state:
"It's advisable to stick to two-letter language codes."
That would be fine normally, but a client has customers in different countries where language-difference within the base language actually matters.
So I really need 'de-DE' and 'de-CH' on this one (for example).
How can I achieve this? I believe the code of the extension itself only wants to check on 2 digits.
Have you tried using de
and ch
to differentiate between the two?
I did, and that broke the whole translation principle.
In vendor/bolt/labels/src/LabelsExtension.php line 93 you can actually see the extension cutting back to the '2 digit version'
Set the current language, always based on a 2-letter code
$lang = substr($request->getLocale(), 0, 2);
Hmm. Do you have a suggestion on how to fix this?
Well in a functional sense the code should count the digits. If the label (the label's label) is 2 digits long, then the first part of the 'locale' can be matched. If the label is 2+ digits (nl-NL, but also nl_NL) it should try to match 5 digits of the locale.
In a technical sense, all relevant code seems to be in LabelsExtension.php.
Somehow the extension would need to 'allow' for 2 OR 5 digit languagecodes. Of course, the admin would need to use one or the other in the labels matrix... or things might break.