Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions i18n.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@
"localName": "Tagalog",
"langDir": "ltr",
"dateFormat": "MM/DD/YYYY",
"forceLocalName": true,
"validISO639_1": true
},
{
Expand Down
1 change: 1 addition & 0 deletions src/intl/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"language-te": "Telugu",
"language-th": "Thai",
"language-tk": "Turkmen",
"language-tl": "Tagalog",
"language-tr": "Turkish",
"language-uk": "Ukrainian",
"language-ur": "Urdu",
Expand Down
2 changes: 1 addition & 1 deletion src/intl/tl/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
"language-te": "Telugu",
"language-th": "Thai",
"language-tk": "Turkmen",
"language-tl": "Tagalog",
"language-tr": "Turkish",
"language-uk": "Ukrainian",
"language-ur": "Urdu",
Expand Down Expand Up @@ -432,5 +433,4 @@
"zero-knowledge-proofs": "Mga zero-knowledge proof",
"ethereum-vs-bitcoin": "Ethereum vs. Bitcoin",
"nav-ethereum-vs-bitcoin-description": "Unawain ang mga pagkakaiba sa pagitan ng Ethereum at Bitcoin"

}
7 changes: 4 additions & 3 deletions src/lib/nav/localeToDisplayInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ export const localeToDisplayInfo = (
// If i18nSource (fetched from `language-{locale}` in current namespace)
// is not translated (output === englishName), or not available
// (output === i18nKey), use the Intl.DisplayNames result as fallback
const sourceName = [i18nKey, englishName].includes(i18nSource)
? fallbackSource
: i18nSource
const sourceName =
[i18nKey, englishName].includes(i18nSource) && !i18nItem.forceLocalName
? fallbackSource
: i18nSource

// Get "target" display name (Language choice displayed in that language)
const fallbackTarget = new Intl.DisplayNames([localeOption], {
Expand Down
8 changes: 8 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ export type I18nLocale = {
localName: string
langDir: Direction
dateFormat: string
/**
* @property forceLocalName - Optional flag to indicate that the local name should be used instead of the fallback from `Intl.DisplayName`.
* Fallback used when locale language name matches English name.
* Set to `true` in cases where the result from `Intl.DisplayName` not desired.
* When enabled, ensure that the `"language-{code}"` string is available in both `en/common.json` and `{code}/common.json` files.
* @example Tagalog (tl) results in "Filipino", which is not desired
*/
forceLocalName?: boolean
}

export type Languages = {
Expand Down