Feature #7720

Implement automatic locale detection

Added by Karol Gusak about 5 years ago. Updated almost 5 years ago.

Status:Resolved Start date:
Priority:Must have Due date:
Assigned To:Karol Gusak % Done:

100%

Category:I18n
Target version:-
PHP Version: Complexity:
Has patch:

Description

Locale detection can be done in web application framework in three ways:
  • using HTTP "Accept-Language" header
  • using user preference from cookies (if he already was visiting our website)
  • by letting user choose preferred locale by UI

All these methods will be supported by i18n / l10n subsystem.


Related issues

related to TYPO3.Flow - Feature #6724: Internationalization, locale, multi-language ect. Resolved

Associated revisions

Revision 5ef44700
Added by Karol Gusak about 5 years ago

[+FEATURE] FLOW3 (Locale): Basic automatic locale detection added. Relates to #7720.

Revision 02b74873
Added by Karol Gusak about 5 years ago

[+FEATURE] FLOW3 (Locale): Support for list of available locales to set manually in configuration, as an alternative for automatic filesystem scanning. Relates to #7720.

Revision a69fef9d
Added by Karol Gusak about 5 years ago

[+FEATURE] FLOW3 (Locale): Implemented a tree of locales in order to support locales hierarchy. Automatic locale detection rewritten. Relates to #7720.

Revision 4d0443cf
Added by Karsten Dambekalns about 5 years ago

[~TASK] FLOW3 (Locale): Review results for the Locale subsystem, mostly changing naming and some coding style issues. Relates to #7720.

Revision 7bed05c1
Added by Karol Gusak about 5 years ago

[~TASK] FLOW3 (Locale): Reimplemented the locale collection structure and dependent classes, cleaned the naming. Relates to #7720.
[+FEATURE] FLOW3 (Locale): Added basic support for locale-dependent resources. Relates to #7721.

Revision d98edc46
Added by Karol Gusak about 5 years ago

[+FEATURE] FLOW3 (Locale): Collection of available locales is cached from now. Relates to #7720.

History

#1 Updated by Karol Gusak about 5 years ago

  • Priority changed from Should have to Must have

#2 Updated by Karol Gusak about 5 years ago

  • Status changed from New to Needs Feedback
  • % Done changed from 0 to 50

The commit in Revision 4308 was done mainly for the record. I plan to reimplement this part anyway in order to use tree of Locales (not array of Locales), as there should be a hierarchical relation between Locales, as it was planned.

Also, I'm unsure about the directory structure for locales. I planned to support directories named as locale identifiers, in [Package]/Resources/Private/Locale and Public/Locale folders, eg:
FLOW3/Resources/Private/Locale/en_GB
FLOW3/Resources/Public/Locale/ru_Cyryl_RU
... etc

Different classes would interpret how the structure in these folders looks like (eg translation messages under the private path, and locale-dependent images under the public path).

This seems pretty clear structure for me. But on other hand, where to place the CLDR data folder (and maybe others in the future too)? As for now it's in FLOW3/Resources/Private/Locale/CLDR so it would be interpreted as a locale folder. I thought about a "root" folder which would be the special case ("root" in general is used in CLDR so it probably will be needed in some logic anyway).

What do you think about that?

#3 Updated by Karol Gusak about 5 years ago

  • % Done changed from 50 to 90

I rewrote the Detector class and implemented a LocaleTree class, which represents all available locales in a tree structure and provides convenient methods to obtain best-matching locales etc. More tests need to be written, but as for now all seems to work as expected ;-).

This issue is almost done, I need a response for my last update's questions. I also not sure yet how to make the framework to automatically provide the default Locale object on start.

#4 Updated by Karsten Dambekalns about 5 years ago

  • Status changed from Needs Feedback to Accepted
I just discussed this with Robert and we would opt for a different solution:
  • all files should be localizable (graphics, css, translations, templates, ...)
  • to do that provide a service you can ask for a localized version to a filename
  • translation code, resource handling, ... would use that service
  • locale identifiers are embedded in filenames, so no folders for that purpose (foobar.png, foobar.en.png, foobar.en_GB.png)
    That would solve the "Locale" folder name clash as well. As for a folder that contains label translations a name like "Labels" or "Translations" would be better than "Locale" as well, because it's not a locale in there.

#5 Updated by Karol Gusak about 5 years ago

Removed the tree as k-fish said (now there are just two arrays :-) ). Implemented the idea with locale resources. I think it's almost all for this issue (needs to cache result of filesystem scanning for locale detection yet).

#6 Updated by Karol Gusak about 5 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 90 to 100

Also available in: Atom PDF