Issue Bug Closed

#107990Not possible to use en-* locales for translation fiels if system default language is not english

Daniel Siepmann 11/06/25, 09:34 updated 11/09/26, 18:21

Description

Some projects use a different language as default language than English, e.g. German.
Those than also use locallang.xlf files to provide the default language German and en.locallang.xlf to provide English.

One can now configure a site with German as default language and English with a locale e.g. en-GB.
Those will not find the correct translation file when used via TypoScript data = LLL approach.
That’s due to the implementation of Locales->getLocaleDependencies() which has explicit code for en. This prevents a fallback to en lookups.

Steps to reproduce:
1. Set Up a page with German as default and English with locale en-GB as translation.
2. Add TypoScript:

page.5 = TEXT
page.5.data = LLL:EXT:sitepackage/Resources/Private/Language/locallang.xlf:test

3. Add a sitepackage/Resources/Private/Language/locallang.xlf file as well as sitepackage/Resources/Private/Language/en.locallang.xlf file, both with a translated test key.

I’ve only found and inspected this in V13. It worked in V11. I’ve not checked v12.

Reviews 2

History 13

  1. Daniel Siepmann commented <span data-processor="relativetime" data-value="2025-11-06T09:35:49+00:00" > 11/06/25, 09:35 </span>

    Our patch/workaround looks like this:

    diff --git a/typo3/sysext/core/Classes/Localization/Locales.php b/typo3/sysext/core/Classes/Localization/Locales.php
    index 567971ab83a..39accd9acd1 100644
    --- a/typo3/sysext/core/Classes/Localization/Locales.php
    +++ b/typo3/sysext/core/Classes/Localization/Locales.php
    @@ -239,18 +239,12 @@ class Locales implements SingletonInterface
             // $this->localeDependencies
             if ($dependencies === [] && str_contains($locale, '_')) {
                 [$languageIsoCode] = explode('_', $locale);
    -            // "en" = "default" is always implicitly the default fallback dependency
    -            if ($languageIsoCode !== 'en') {
    -                $dependencies[] = $languageIsoCode;
    -                $dependencies = array_merge($dependencies, $this->getLocaleDependencies($languageIsoCode));
    -            }
    +            $dependencies[] = $languageIsoCode;
    +            $dependencies = array_merge($dependencies, $this->getLocaleDependencies($languageIsoCode));
             } elseif ($dependencies === [] && str_contains($locale, '-')) {
                 [$languageIsoCode] = explode('-', $locale);
    -            // "en" = "default" is always implicitly the default fallback dependency
    -            if ($languageIsoCode !== 'en') {
    -                $dependencies[] = $languageIsoCode;
    -                $dependencies = array_merge($dependencies, $this->getLocaleDependencies($languageIsoCode));
    -            }
    +            $dependencies[] = $languageIsoCode;
    +            $dependencies = array_merge($dependencies, $this->getLocaleDependencies($languageIsoCode));
             }
             return array_unique($dependencies);
         }
  2. Garvin Hicking commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2025-11-06T19:28:10+00:00" > 11/06/25, 19:28 </span>

    I suppose due to the changes in v14 with symfony/translate this will become an even bigger issue.

    I think it would be more advisable to have locallang.xlf with english contents and de.locallang.xlf with german ones. This will prevent you from future pain.

    You can still map the default language to german then.

  3. Hannes Lau commented <span data-processor="relativetime" data-value="2025-11-07T06:55:38+00:00" > 11/07/25, 06:55 </span>

    Hi @ghi !

    Forcing english as the source language for the label translation would present us with a different set of issues. See https://forge.typo3.org/issues/104468

    > We have a lot of projects where the sites are created in German and later translated to English. This is true for the site content but also for the xlf labels. So our source locallang.xlf files are in German. Translation agencies create the translation files, such as en.locallang.xlf or zh.locallang.xlf. It is way easier for them to work forward from the locallang.xlf with the source tags, then backwards (target -> source) from a translated de.locallang.xlf.

    If in reality, we translate from German to English, it is difficult to force it the other way around in the xlfs. I can see why the en -> * translation has value for TYPO3 and public extensions. But for project code, it seems necessary to me, to be able to define the translation source language for whatever the project really uses.

    The same holds true for the default language for database content. It would be a pain, if we would be forced to create fake content in English first, to then translate it to other languages. Same as the xlfs.

  4. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-11-07T20:33:47+00:00" > 11/07/25, 20:33 </span>

    Not sure I’m getting this accross properly.

    The idea is this:
    - locallang.xlf: ALWAYS english
    - de.locallanf.xlf: ALWAYS german

    If you create new labels that are not yet needed in english, create a dummy entry in locallang.xlf – or even insert the german label there.

    In the backend, map your site config language id=0 to “german”, id=1 to “english”.

    This way you should be able to have default german contents, but proper english-default-based XLFs.

    This feels a bit weird at first (and I hope I didn’t choose this approach in error) – but it will make XLFs work, and also “german first” sites too.

    This way also all extensions that work with non-german files will display proper english labels as fallbacks.

    If I’m misunderstanding your point, maybe you can try again to explain why that approach could not work. I’m feeling as if I’m missing something.

    Hannes Lau wrote in #note-4:
    > Hi @ghi !
    >
    > Forcing english as the source language for the label translation would present us with a different set of issues. See https://forge.typo3.org/issues/104468
    >
    > > We have a lot of projects where the sites are created in German and later translated to English. This is true for the site content but also for the xlf labels. So our source locallang.xlf files are in German. Translation agencies create the translation files, such as en.locallang.xlf or zh.locallang.xlf. It is way easier for them to work forward from the locallang.xlf with the source tags, then backwards (target -> source) from a translated de.locallang.xlf.
    >
    >
    > If in reality, we translate from German to English, it is difficult to force it the other way around in the xlfs. I can see why the en -> * translation has value for TYPO3 and public extensions. But for project code, it seems necessary to me, to be able to define the translation source language for whatever the project really uses.
    >
    > The same holds true for the default language for database content. It would be a pain, if we would be forced to create fake content in English first, to then translate it to other languages. Same as the xlfs.

  5. Hannes Lau commented <span data-processor="relativetime" data-value="2025-11-08T10:16:12+00:00" > 11/08/25, 10:16 </span>

    Hi @ghi !

    Your approach works, but it is cumbersome. We usually have the German original source texts first and we use translation software or translation agencies to translate them into other languages (including English). I will compare two scenarios:

    English as fake source language

    Create a dummy label in locallang.xlf, possibly with the german content

    <!-- locallang.xlf -->
    <source>translate to en: Deutsches Label</source>

    Create the real german translation

    <!-- de.locallang.xlf -->
    <source>translate to en: Deutsches Label</source>
    <target>Deutsches Label</target>

    From now on, to keep things consistent, I have to change three lines in two files, every time the label changes. To add a new key, I have to update two files.

    <!-- locallang.xlf -->
    <source>translate to en: Deutsches Label verbessert</source>
    <!-- de.locallang.xlf -->
    <source>translate to en: Deutsches Label verbessert</source>
    <target>Deutsches Label verbessert</target>

    Of course I could just use a dummy value for the source, or the key as source. I still have to manage new keys in two files though.

    Now, I would like to ship the file for translation to the agency. I would like them to translate from German to English, Italian and French. Which file do I ship? For english, I would probably send them the de.locallang.xlf with instructions to translate backwards to english, from `target` to `source`. That needs some explaining. For Italian and French, I do not have a proper translation file. So I implement scripts to create proper de->* translation files and import de->* translation files back into the fake en->* scheme.

    Once the english translation is complete (next to fr, it, …) I have a `source` change. So I need to update the `source` elements in all my translation files. Again, with scripting.

    Real source language as xlf source language

    The workflow with my real source language as the xlf source language is a lot easier.

    Create the real label in the German locallang.xlf

    <!-- locallang.xlf -->
    <source>Deutsches Label</source>

    Changes and adding labels during development can be done in one single file.

    <!-- locallang.xlf -->
    <source>Deutsches Label verbessert</source>

    To get the translation files, I ship my `locallang.xlf` to the agencies and ask them to create en, fr, it translations. If I happen to be nice, I create the en.locallang.xlf, fr.locallang.xlf, … files by copying the locallang.xlf files and update target-language in the header. But this is usually not necessary. The translation agency just has to add targets. This seems to be the default for translation agencies and translation management software.

    Once the translation files (it.locallang.xlf, en.locallang.xlf, …) arrive from the translation agency, I simply copy them in to the `Languages` folder. No `source` update is needed, as the source did not change.

    Sumup

    In some projects we have hundreds of translation items and 30+ target languages. So managing them all in a fake en->* translation scheme (while we really do de->*) is a pain that I would like to avoid.

  6. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-11-08T11:27:57+00:00" > 11/08/25, 11:27 </span>

    Hhmm… but the “source” in the german file is optional. Just leave it out if that is the lead.
    Only translate the “locallang.xlf” files?

    Also, scripting could normalize the files.

    What I’m trying to say: v14 fixates english as the base language key. That’s what symfony also propagates and has as a lead for symfony/translation which we rely on now. From what I understand we won’t be able to make that optional. (If any other core dev reads this and I’m wrong, I’m happy to stand corrected)

  7. Hannes Lau commented <span data-processor="relativetime" data-value="2025-11-08T14:49:38+00:00" > 11/08/25, 14:49 </span>

    > Hhmm… but the “source” in the german file is optional. Just leave it out if that is the lead.

    Yes, I am aware. But that would still not give me files that I can send to the translation agency to translate de->en or de->it. Also, please be aware that translation is an ongoing process. New keys get added, new languages need to be added etc. In all this cases it is way easier for us to have the translation source in the xlf files in the real source language of the translation process.

    > Also, scripting could normalize the files.

    This what we currently do for projects where de is not the xlf source. The real de->* translation files are outside of the TYPO3 context and get compiled to en->* during the project build.

    > What I’m trying to say: v14 fixates english as the base language key. That’s what symfony also propagates and has as a lead for symfony/translation which we rely on now.

    To my eyes, we should really avoid fixating en as the source language for xlf translations. There are many projects that start out in a different language and translate to en later. Can this still be avoided?

  8. Benni Mack commented <span data-processor="relativetime" data-value="2026-01-04T20:45:10+00:00" > 01/04/26, 20:45 </span>

    Looking at this change, I believe we’re moving in a good direction solving the problem you mentioned, Hannes, right? https://review.typo3.org/c/Packages/TYPO3.CMS/+/91994

  9. Ayke Halder commented <span data-processor="relativetime" data-value="2026-10-23T15:30:22+00:00" > 10/23/26, 15:30 </span>

    With the change mentioned by @benni a working setup is:

    • Configure ‘default’ language to use de locale.
    • Strictly use de.locallang.xlf for german base.
    • Strictly use en.locallang.xlf with english translation. (locallang.xlf might also work, but better don’t use anymore outside of ‘extension base translation’ context.)

    That said, with these latest changes you can actually have files like this:

    de.locallang.xlf:

    <?xml version="1.0" encoding="UTF-8"?>
    <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
      <file source-language="de">
        <header/>
        <body>
          <trans-unit id="documentation">
            <source>Dokumentation</source>
          </trans-unit>
    …

    en.locallang.xlf:

    (locallang.xlf might also work, but better don’t use)

    
    <?xml version="1.0" encoding="UTF-8"?>
    <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
      <file source-language="de" target-language="en">
        <header/>
        <body>
          <trans-unit id="documentation">
            <source>Dokumentation</source>
            <target>documentation</target>
          </trans-unit>
    …

    See above how:

    • The ‘de’ file is an original without translation (<file source-language="de">)
    • The ‘en’ file is actually a translation of ‘de’ (<file source-language="de" target-language="en">)

    Very important: Ensure source-language="…" and target-language="…" are set as described – otherwise it will not work.

  10. Benni Mack commented and changed status Needs Feedback Closed <span data-processor="relativetime" data-value="2026-11-09T18:21:39+00:00" > 11/09/26, 18:21 </span>

    This is fixed on main (v14) by #110175 (“Localize labels for locale with country-code”, https://review.typo3.org/c/Packages/TYPO3.CMS/+/92466). The en exclusion in Locales::getLocaleDependencies() is gone, so en-GB now falls back to en and loads en.locallang.xlf.

    Note for German-default setups: en now always comes before default in the fallback chain. With German in locallang.xlf, a German site shows the English label from en.locallang.xlf for every key that has no de.locallang.xlf entry. Use the layout Ayke described in note-10: German in de.locallang.xlf (source-language="de"), English in en.locallang.xlf (source-language="de" target-language="en").

    The change is main-only, so 13.4 behaves as reported. Closing as resolved for v14.