Skip to content

Commit 7b78104

Browse files
authored
[TASK] Add Introduction and Overhaul Localization API Chapters (#6040)
* [TASK] Add Introduction and Overhaul Localization API Chapters Releases: main, 13.4 * [TASK] Add Introduction and Overhaul Localization API Chapters Releases: main, 13.4
1 parent 4b4773f commit 7b78104

File tree

5 files changed

+54
-18
lines changed

5 files changed

+54
-18
lines changed
Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
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
================
67
Localization 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
*

Documentation/ApiOverview/Localization/LocalizationApi/LanguageService.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ LanguageService
66
===============
77

88
This 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:`\TYPO3\CMS\Core\Localization\LanguageService` **should not**
1011
be created directly, therefore its constructor is internal. Create a
11-
:php:`LanguageService` with the :ref:`LanguageServiceFactory-api`.
12+
:php-short:`\TYPO3\CMS\Core\Localization\LanguageService` with the
13+
:ref:`LanguageServiceFactory-api`.
1214

1315
In the backend context a :php:`LanguageService` is stored in the global
1416
variable :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:`\TYPO3\CMS\Core\Localization\LanguageService` 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

Documentation/ApiOverview/Localization/LocalizationApi/LanguageServiceFactory.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
LanguageServiceFactory
66
======================
77

8-
This factory class is for retrieving the :ref:`LanguageService <LanguageService-api>`
8+
The :php:`\TYPO3\CMS\Core\Localization\LanguageServiceFactory` class is
9+
for retrieving the :ref:`LanguageService <LanguageService-api>`
910
at runtime, which then is used to translate strings in plain PHP. For examples
1011
see :ref:`extension-localization-php`. Creates a :ref:`LanguageService-api`
1112
that can then be used for localizations.

Documentation/ApiOverview/Localization/LocalizationApi/Locale.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff 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

Documentation/ApiOverview/Localization/LocalizationApi/LocalizationUtility.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
LocalizationUtility (Extbase)
66
=============================
77

8-
This class is used to translate strings within Extbase context. For an example
8+
The :php:`TYPO3\CMS\Extbase\Utility\LocalizationUtility` class is used to
9+
translate strings within Extbase context. For an example
910
see :ref:`extension-localization-extbase`.
1011

1112
.. include:: _LocalizationUtilityApi.rst.txt

0 commit comments

Comments
 (0)