Fix missing translations in TYPO3 and Snowbabel

For some years the language codes TYPO3 used for translations where based on the ISO country codes - not the ISO language codes! That was changed with TYPO3 4.6. That's why it might happen that translations go missing on the website if you do not move the language files correctly after updating from TYPO3 4.5.

This issue gets even more confusing if you use snowbabel. For some time they also used the faulty language codes from TYPO3 4.5, but then switched to the new labels in version 3.6.2. There you can also lose your translations if you don't take the proper actions.

Affected languages

There are quite a few languages that were affected by the language code switch. As a rule of thumb these are languages that have a country code other than the language code for the main spoken language there.

If you don't use any of those languages in your projects, you might stop reading right here, because you won't have to change anything.

Here is a conclusive list of all affected language codes

  • Bosnian: ba -> bs

  • Brazilian Portugese: br -> pt_BR

  • Chinese (Traditional): hk -> zh

  • Czech: cz -> cs

  • Danish: dk -> da

  • French (Canada): qc -> fr_CA

  • Galician: ga -> gl

  • Georgian: ge -> ka

  • Greek: gr -> el

  • Greenlandic: gl -> kl

  • Japanese: jp -> ja

  • Korean: kr -> ko

  • Malay: my -> ms

  • Slovenian: si -> sl

  • Swedish: se -> sv

  • Ukraine: ua -> uk

  • Vietnamese: vn -> vi

All the language codes comply to ISO 639-1 with one notable exception: Simplified Chinese (that would also be zh like Traditional Chinese) maps to ch.

1. Change config.language

Change the TypoScript for your configured languages to the new language codes like so

# was "jp" before
config.language = ja

There are lists of all supported language keys in t3lib_l10n_locales and Core\Localization\Locales respectively. And you could even add your own.

2. Move translation files in typo3conf/l10n

Now you have to move some files in the typo3conf/l10n folder. This script does that for you:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
TARGETPATH=.
 
function moveL10nFiles {
  # $1 - old language code
  # $2 - new language code
 
  if [ -d "${TARGETPATH}/typo3conf/l10n/$1" ]; then
    echo "moving translation files $1->$2"
    mv ${TARGETPATH}/typo3conf/l10n/$1 ${TARGETPATH}/htdocs/typo3conf/l10n/$2
 
    # modify language keys in XML
    find ${TARGETPATH}/typo3conf/l10n/$2 -name "*.xml" -print0 | xargs --null sed -i "s/index=\"${1}\"/index=\"${2}\"/g"
 
    # rename the files
    find ${TARGETPATH}/htdocs/typo3conf/l10n/$2 -name "*.xml" -print | sed "s/(.*)${1}.(.*)/\"\0\" \"\1${2}.\2\"/g" | xargs -L 1 mv
    # the sed command maps the current file name to the new file name
    # by appending the modified name right behind the original name. This serves as parameters for the "mv" command
  fi
}
 
# Bosnian
moveL10nFiles "ba" "bs"
# Brazilian Portugese
moveL10nFiles "br" "pt_BR"
# Chinese (Traditional)
moveL10nFiles "hk" "zh"
# Czech
moveL10nFiles "cz" "cs"
# Danish
moveL10nFiles "dk" "da"
# French (Canada)
moveL10nFiles "qc" "fr_CA"
# Galician
moveL10nFiles "ga" "gl"
# Georgian
moveL10nFiles "ge" "ka"
# Greek
moveL10nFiles "gr" "el"
# Greenlandic
moveL10nFiles "gl" "kl"
# Japanese
moveL10nFiles "jp" "ja"
# Korean
moveL10nFiles "kr" "ko"
# Malay
moveL10nFiles "my" "ms"
# Slovenian
moveL10nFiles "si" "sl"
# Swedish
moveL10nFiles "se" "sv"
# Ukraine
moveL10nFiles "ua" "uk"
# Vietnamese
moveL10nFiles "vn" "vi"

3. Update Snowbabel

When using snowbabel, you should update to at least Version 3.6.3. If you want to use Traditional and Simplified Chinese at the same time you should also apply this bugfix.

The update is necessary so that snowbabel uses the new language codes.

4. Run scheduler on snowbabel

Snowbabel comes with a scheduler task called Snowbabel - Indexing. Run that now to crawl the new files and remove the old translations.

5. Fix access to languages in snowbabel

In case editors have access to snowbabel, you might need to grant them rights to the modified language keys again in be_groups. See the field "Translation - Languages" for that.

No Comments yet

Respond to this post