pull/7316/head
Your Name 1 week ago
parent 47dd59367e
commit 7d84856da3

@ -91,9 +91,32 @@ class ExportLanguages extends Command
* *
* @param array<int, string> $langs Valid locale codes (lang/ folders). * @param array<int, string> $langs Valid locale codes (lang/ folders).
*/ */
/**
* Display-name overrides for locale codes that ICU cannot resolve
* correctly. Crowdin uses some non-standard codes (e.g. custom
* languages) that would otherwise render as the wrong language or as
* the raw code via locale_get_display_name().
*
* @var array<string, array{name: string, nativeName: string}>
*/
protected const LOCALE_OVERRIDES = [
// Crowdin custom "Pirate English". BCP-47 would read en-Pirate as
// English, and the old en-PT code collided with English (Portugal).
'en-Pirate' => ['name' => 'English (Pirate)', 'nativeName' => 'English (Pirate)'],
// Klingon. 'tlh' is valid BCP-47 (ICU renders "Klingon"), but ICU has
// no native-name form, so pin both for a consistent label. Mapped from
// Crowdin's tlh-AA (AA is a fake region) via crowdin.yml.
'tlh' => ['name' => 'Klingon', 'nativeName' => 'tlhIngan Hol'],
];
protected function writeLocalesManifest(array $langs): void protected function writeLocalesManifest(array $langs): void
{ {
$locales = array_map(function ($code) { $locales = array_map(function ($code) {
if (isset(self::LOCALE_OVERRIDES[$code])) {
return array_merge(['code' => $code], self::LOCALE_OVERRIDES[$code]);
}
return [ return [
'code' => $code, 'code' => $code,
'name' => locale_get_display_name($code, 'en'), 'name' => locale_get_display_name($code, 'en'),

@ -3,26 +3,40 @@ api_token_env: CROWDIN_PERSONAL_TOKEN
base_path: '.' base_path: '.'
preserve_hierarchy: true preserve_hierarchy: true
# Map Crowdin's non-standard locale codes to clean folder names. Avoids the
# en-PT ↔ English (Portugal) BCP-47 collision and the fake tlh-AA region.
# Applied per file entry below via the *locale_mapping anchor.
# en-PT (Pirate English) -> en-Pirate
# tlh-AA (Klingon) -> tlh (tlh is valid BCP-47; AA is a fake region)
files: files:
- source: /lang/en-US/auth.php - source: /lang/en-US/auth.php
translation: /lang/%locale%/auth.php translation: /lang/%locale%/auth.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: &locale_mapping
locale:
en-PT: en-Pirate
tlh-AA: tlh
- source: /lang/en-US/exception.php - source: /lang/en-US/exception.php
translation: /lang/%locale%/exception.php translation: /lang/%locale%/exception.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
- source: /lang/en-US/helpcenter.php - source: /lang/en-US/helpcenter.php
translation: /lang/%locale%/helpcenter.php translation: /lang/%locale%/helpcenter.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
- source: /lang/en-US/navmenu.php - source: /lang/en-US/navmenu.php
translation: /lang/%locale%/navmenu.php translation: /lang/%locale%/navmenu.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
- source: /lang/en-US/notification.php - source: /lang/en-US/notification.php
translation: /lang/%locale%/notification.php translation: /lang/%locale%/notification.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
# - source: /lang/en-US/pagination.php # - source: /lang/en-US/pagination.php
# translation: /lang/%locale%/pagination.php # translation: /lang/%locale%/pagination.php
@ -31,22 +45,27 @@ files:
- source: /lang/en-US/passwords.php - source: /lang/en-US/passwords.php
translation: /lang/%locale%/passwords.php translation: /lang/%locale%/passwords.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
- source: /lang/en-US/profile.php - source: /lang/en-US/profile.php
translation: /lang/%locale%/profile.php translation: /lang/%locale%/profile.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
- source: /lang/en-US/settings.php - source: /lang/en-US/settings.php
translation: /lang/%locale%/settings.php translation: /lang/%locale%/settings.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
- source: /lang/en-US/site.php - source: /lang/en-US/site.php
translation: /lang/%locale%/site.php translation: /lang/%locale%/site.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
- source: /lang/en-US/timeline.php - source: /lang/en-US/timeline.php
translation: /lang/%locale%/timeline.php translation: /lang/%locale%/timeline.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping
# - source: /lang/en-US/validation.php # - source: /lang/en-US/validation.php
# translation: /lang/%locale%/validation.php # translation: /lang/%locale%/validation.php
@ -55,3 +74,4 @@ files:
- source: /lang/en-US/web.php - source: /lang/en-US/web.php
translation: /lang/%locale%/web.php translation: /lang/%locale%/web.php
skip_untranslated_strings: true skip_untranslated_strings: true
languages_mapping: *locale_mapping

Loading…
Cancel
Save