File tree Expand file tree Collapse file tree 5 files changed +54
-18
lines changed
Documentation/ApiOverview/Localization/LocalizationApi Expand file tree Collapse file tree 5 files changed +54
-18
lines changed Original file line number Diff line number Diff line change 1- .. include :: /Includes.rst.txt
2- .. index ::
3- pair: Localization; API
1+ .. include :: /Includes.rst.txt
2+ .. index ::
3+ pair: Localization; API
4+ .. _localization-api :
45
56================
67Localization API
78================
89
10+ The Localization API provides the building blocks TYPO3 uses to resolve locales
11+ and translate labels from XLIFF files in both Backend and Frontend code. It
12+ covers locale parsing and normalization, creation of context-aware translation
13+ services, and convenient helpers for TypoScript, Extbase and Fluid.
14+
15+ .. card-grid ::
16+ :columns: 1
17+ :columns-md: 2
18+ :gap: 4
19+ :class: pb-4
20+ :card-height: 100
21+
22+ .. card :: `Locale <https://docs.typo3.org/permalink/t3coreapi:locale-api>`_
23+
24+ Parse and normalize IETF BCP 47 language tags (e.g. `de-CH `) to build a
25+ precise locale context for translations.
26+
27+ .. card :: `LanguageServiceFactory <https://docs.typo3.org/permalink/t3coreapi:languageservicefactory-api>`_
28+
29+ Create context-aware `LanguageService <https://docs.typo3.org/permalink/t3coreapi:languageservice-api >`_ instances
30+ at runtime.
31+
32+ .. card :: `LanguageService <https://docs.typo3.org/permalink/t3coreapi:languageservice-api>`_
33+
34+ Translate labels via `LLL:EXT:... ` in PHP; loads XLIFF resources on demand.
35+
36+ .. card :: :ref:`LocalizationUtility (Extbase) <extbase-localization-utility-api>`
37+
38+ Convenience wrapper to translate labels inside Extbase.
39+
40+ .. card :: `Localization in TypoScript <https://docs.typo3.org/permalink/t3coreapi:extension-localization-typoscript>`_
41+
42+ Using `LLL:EXT:... ` labels in TypoScript.
43+
944.. toctree ::
1045 :titlesonly:
1146 :glob:
47+ :hidden:
1248
1349 *
Original file line number Diff line number Diff line change @@ -6,18 +6,21 @@ LanguageService
66===============
77
88This class is used to translate strings in plain PHP. For examples
9- see :ref: `extension-localization-php `. A :php: `LanguageService ` **should not **
9+ see :ref: `extension-localization-php `. A
10+ :php-short: `\T YPO3\C MS\C ore\L ocalization\L anguageService ` **should not **
1011be created directly, therefore its constructor is internal. Create a
11- :php: `LanguageService ` with the :ref: `LanguageServiceFactory-api `.
12+ :php-short: `\T YPO3\C MS\C ore\L ocalization\L anguageService ` with the
13+ :ref: `LanguageServiceFactory-api `.
1214
1315In the backend context a :php: `LanguageService ` is stored in the global
1416variable :php: `$GLOBALS['LANG'] `.
15- In the frontend a :php: `LanguageService ` can be accessed via the contentObject:
16-
17- .. include :: _LanguageService.rst.txt
18-
19- Example: Use
20- ========
17+ In the frontend a :php-short: `\T YPO3\C MS\C ore\L ocalization\L anguageService ` can
18+ be accessed via the contentObject:
2119
2220.. literalinclude :: _ExampleController.php
2321 :caption: EXT:my_extension/Classes/Controller/ExampleController.php (not Extbase)
22+
23+ In CLI context `$GLOBALS['LANG'] ` is also not available and has to be
24+ instantiated manually.
25+
26+ .. include :: _LanguageService.rst.txt
Original file line number Diff line number Diff line change 55LanguageServiceFactory
66======================
77
8- This factory class is for retrieving the :ref: `LanguageService <LanguageService-api >`
8+ The :php: `\T YPO3\C MS\C ore\L ocalization\L anguageServiceFactory ` class is
9+ for retrieving the :ref: `LanguageService <LanguageService-api >`
910at runtime, which then is used to translate strings in plain PHP. For examples
1011see :ref: `extension-localization-php `. Creates a :ref: `LanguageService-api `
1112that can then be used for localizations.
Original file line number Diff line number Diff line change @@ -50,16 +50,11 @@ object for translations:
5050.. literalinclude :: _LocaleExample.php
5151 :caption: EXT:my_extension/Classes/LocaleExample.php
5252
53-
5453.. _IETF RFC 5646 : https://www.rfc-editor.org/rfc/rfc5646.html
5554.. _ISO 639-1 : https://en.wikipedia.org/wiki/ISO_639-1
5655.. _ISO 639-2 : https://en.wikipedia.org/wiki/ISO_639-2
5756.. _ISO 3166-1 : https://en.wikipedia.org/wiki/ISO_3166-1
5857.. _ISO 15924 : https://en.wikipedia.org/wiki/ISO_15924
5958.. _tags and subtags : https://www.rfc-editor.org/rfc/rfc5646.html#section-2
6059
61-
62- API
63- ===
64-
6560.. include :: _Locale.rst.txt
Original file line number Diff line number Diff line change 55LocalizationUtility (Extbase)
66=============================
77
8- This class is used to translate strings within Extbase context. For an example
8+ The :php: `TYPO3\C MS\E xtbase\U tility\L ocalizationUtility ` class is used to
9+ translate strings within Extbase context. For an example
910see :ref: `extension-localization-extbase `.
1011
1112.. include :: _LocalizationUtilityApi.rst.txt
You can’t perform that action at this time.
0 commit comments