mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 14:43:25 +00:00
fix: country code mapping
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import type { LanguageCode } from "iso-639-1";
|
||||||
import type { ContentCaption } from "subsrt-ts/dist/types/handler";
|
import type { ContentCaption } from "subsrt-ts/dist/types/handler";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
import { MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons";
|
||||||
@@ -14,7 +15,10 @@ import { FlagIcon } from "../FlagIcon";
|
|||||||
import { MWButton } from "../ui/Button";
|
import { MWButton } from "../ui/Button";
|
||||||
import { Controls } from "./Controls";
|
import { Controls } from "./Controls";
|
||||||
import { Settings } from "./settings/Sheet";
|
import { Settings } from "./settings/Sheet";
|
||||||
import { getPrettyLanguageNameFromLocale } from "./utils";
|
import {
|
||||||
|
getCountryCodeFromLanguage,
|
||||||
|
getPrettyLanguageNameFromLocale,
|
||||||
|
} from "./utils";
|
||||||
|
|
||||||
const parseCaption = async (
|
const parseCaption = async (
|
||||||
caption: Stream["captions"][0],
|
caption: Stream["captions"][0],
|
||||||
@@ -128,7 +132,11 @@ export const CaptionsSelector = () => {
|
|||||||
borderRadius="$5"
|
borderRadius="$5"
|
||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
>
|
>
|
||||||
<FlagIcon languageCode={caption.language} />
|
<FlagIcon
|
||||||
|
languageCode={getCountryCodeFromLanguage(
|
||||||
|
caption.language as LanguageCode,
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
title={getPrettyLanguageNameFromLocale(caption.language) ?? ""}
|
title={getPrettyLanguageNameFromLocale(caption.language) ?? ""}
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import type { LanguageCode } from "iso-639-1";
|
||||||
import iso from "iso-639-1";
|
import iso from "iso-639-1";
|
||||||
|
|
||||||
export const mapMillisecondsToTime = (milliseconds: number): string => {
|
export const mapMillisecondsToTime = (milliseconds: number): string => {
|
||||||
@@ -22,3 +23,195 @@ export const mapMillisecondsToTime = (milliseconds: number): string => {
|
|||||||
export function getPrettyLanguageNameFromLocale(locale: string): string | null {
|
export function getPrettyLanguageNameFromLocale(locale: string): string | null {
|
||||||
return iso.getName(locale);
|
return iso.getName(locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getCountryCodeFromLanguage = (
|
||||||
|
languageCode: LanguageCode,
|
||||||
|
): string => {
|
||||||
|
return languageToCountryMap[languageCode] || "";
|
||||||
|
};
|
||||||
|
|
||||||
|
const languageToCountryMap: Record<LanguageCode, string> = {
|
||||||
|
en: "US", // English - United States
|
||||||
|
es: "ES", // Spanish - Spain
|
||||||
|
fr: "FR", // French - France
|
||||||
|
zh: "CN", // Mandarin - China
|
||||||
|
ar: "SA", // Arabic - Saudi Arabia
|
||||||
|
de: "DE", // German - Germany
|
||||||
|
ru: "RU", // Russian - Russia
|
||||||
|
pt: "PT", // Portuguese - Portugal
|
||||||
|
it: "IT", // Italian - Italy
|
||||||
|
ja: "JP", // Japanese - Japan
|
||||||
|
ko: "KR", // Korean - South Korea
|
||||||
|
hi: "IN", // Hindi - India
|
||||||
|
sv: "SE", // Swedish - Sweden
|
||||||
|
nl: "NL", // Dutch - Netherlands
|
||||||
|
pl: "PL", // Polish - Poland
|
||||||
|
tr: "TR", // Turkish - Turkey
|
||||||
|
el: "GR", // Greek - Greece
|
||||||
|
he: "IL", // Hebrew - Israel
|
||||||
|
vi: "VN", // Vietnamese - Vietnam
|
||||||
|
th: "TH", // Thai - Thailand
|
||||||
|
cs: "CZ", // Czech - Czech Republic
|
||||||
|
da: "DK", // Danish - Denmark
|
||||||
|
fi: "FI", // Finnish - Finland
|
||||||
|
hu: "HU", // Hungarian - Hungary
|
||||||
|
no: "NO", // Norwegian - Norway
|
||||||
|
ro: "RO", // Romanian - Romania
|
||||||
|
sk: "SK", // Slovak - Slovakia
|
||||||
|
sl: "SI", // Slovenian - Slovenia
|
||||||
|
uk: "UA", // Ukrainian - Ukraine
|
||||||
|
bg: "BG", // Bulgarian - Bulgaria
|
||||||
|
hr: "HR", // Croatian - Croatia
|
||||||
|
lt: "LT", // Lithuanian - Lithuania
|
||||||
|
lv: "LV", // Latvian - Latvia
|
||||||
|
et: "EE", // Estonian - Estonia
|
||||||
|
sr: "RS", // Serbian - Serbia
|
||||||
|
bs: "BA", // Bosnian - Bosnia and Herzegovina
|
||||||
|
mk: "MK", // Macedonian - North Macedonia
|
||||||
|
sq: "AL", // Albanian - Albania
|
||||||
|
mt: "MT", // Maltese - Malta
|
||||||
|
is: "IS", // Icelandic - Iceland
|
||||||
|
ga: "IE", // Irish - Ireland
|
||||||
|
cy: "GB", // Welsh - United Kingdom
|
||||||
|
eu: "ES", // Basque - Spain
|
||||||
|
ca: "ES", // Catalan - Spain
|
||||||
|
gl: "ES", // Galician - Spain
|
||||||
|
af: "ZA", // Afrikaans - South Africa
|
||||||
|
sw: "TZ", // Swahili - Tanzania
|
||||||
|
am: "ET", // Amharic - Ethiopia
|
||||||
|
so: "SO", // Somali - Somalia
|
||||||
|
ha: "NG", // Hausa - Nigeria
|
||||||
|
ig: "NG", // Igbo - Nigeria
|
||||||
|
yo: "NG", // Yoruba - Nigeria
|
||||||
|
rw: "RW", // Kinyarwanda - Rwanda
|
||||||
|
ny: "MW", // Chichewa - Malawi
|
||||||
|
mg: "MG", // Malagasy - Madagascar
|
||||||
|
ln: "CD", // Lingala - Democratic Republic of the Congo
|
||||||
|
tg: "TJ", // Tajik - Tajikistan
|
||||||
|
uz: "UZ", // Uzbek - Uzbekistan
|
||||||
|
tk: "TM", // Turkmen - Turkmenistan
|
||||||
|
ky: "KG", // Kyrgyz - Kyrgyzstan
|
||||||
|
mn: "MN", // Mongolian - Mongolia
|
||||||
|
ps: "AF", // Pashto - Afghanistan
|
||||||
|
ur: "PK", // Urdu - Pakistan
|
||||||
|
fa: "IR", // Persian (Farsi) - Iran
|
||||||
|
ku: "IQ", // Kurdish - Iraq
|
||||||
|
sd: "PK", // Sindhi - Pakistan
|
||||||
|
ne: "NP", // Nepali - Nepal
|
||||||
|
si: "LK", // Sinhala - Sri Lanka
|
||||||
|
km: "KH", // Khmer - Cambodia
|
||||||
|
lo: "LA", // Lao - Laos
|
||||||
|
my: "MM", // Burmese - Myanmar
|
||||||
|
ka: "GE", // Georgian - Georgia
|
||||||
|
hy: "AM", // Armenian - Armenia
|
||||||
|
az: "AZ", // Azerbaijani - Azerbaijan
|
||||||
|
bm: "ML", // Bambara - Mali
|
||||||
|
ff: "SN", // Fulfulde - Senegal
|
||||||
|
ti: "ER", // Tigrinya - Eritrea
|
||||||
|
xh: "ZA", // Xhosa - South Africa
|
||||||
|
zu: "ZA", // Zulu - South Africa
|
||||||
|
ms: "MY", // Malay - Malaysia
|
||||||
|
id: "ID", // Indonesian - Indonesia
|
||||||
|
jv: "ID", // Javanese - Indonesia
|
||||||
|
su: "ID", // Sundanese - Indonesia
|
||||||
|
tl: "PH", // Tagalog - Philippines
|
||||||
|
ml: "IN", // Malayalam - India
|
||||||
|
te: "IN", // Telugu - India
|
||||||
|
ta: "IN", // Tamil - India
|
||||||
|
mr: "IN", // Marathi - India
|
||||||
|
bn: "BD", // Bengali - Bangladesh
|
||||||
|
gu: "IN", // Gujarati - India
|
||||||
|
kn: "IN", // Kannada - India
|
||||||
|
or: "IN", // Oriya - India
|
||||||
|
pa: "IN", // Punjabi - India
|
||||||
|
aa: "ET", // Afar - Ethiopia
|
||||||
|
ab: "GE", // Abkhazian - Georgia
|
||||||
|
ae: "IR", // Avestan - Iran
|
||||||
|
ak: "GH", // Akan - Ghana
|
||||||
|
an: "ES", // Aragonese - Spain
|
||||||
|
as: "IN", // Assamese - India
|
||||||
|
av: "RU", // Avaric - Russia
|
||||||
|
ay: "BO", // Aymara - Bolivia
|
||||||
|
ba: "RU", // Bashkir - Russia
|
||||||
|
be: "BY", // Belarusian - Belarus
|
||||||
|
bi: "VU", // Bislama - Vanuatu
|
||||||
|
bo: "CN", // Tibetan - China
|
||||||
|
br: "FR", // Breton - France
|
||||||
|
ce: "RU", // Chechen - Russia
|
||||||
|
ch: "GU", // Chamorro - Guam
|
||||||
|
co: "FR", // Corsican - France
|
||||||
|
cr: "CA", // Cree - Canada
|
||||||
|
cu: "RU", // Church Slavic - Russia
|
||||||
|
cv: "RU", // Chuvash - Russia
|
||||||
|
dv: "MV", // Dhivehi - Maldives
|
||||||
|
dz: "BT", // Dzongkha - Bhutan
|
||||||
|
ee: "GH", // Ewe - Ghana
|
||||||
|
eo: "—", // Esperanto - International (Constructed Language)
|
||||||
|
fj: "FJ", // Fijian - Fiji
|
||||||
|
fo: "FO", // Faroese - Faroe Islands
|
||||||
|
fy: "NL", // Western Frisian - Netherlands
|
||||||
|
gd: "GB", // Scottish Gaelic - United Kingdom
|
||||||
|
gn: "PY", // Guarani - Paraguay
|
||||||
|
gv: "IM", // Manx - Isle of Man
|
||||||
|
ho: "PG", // Hiri Motu - Papua New Guinea
|
||||||
|
ht: "HT", // Haitian Creole - Haiti
|
||||||
|
hz: "NA", // Herero - Namibia
|
||||||
|
ia: "—", // Interlingua - International (Constructed Language)
|
||||||
|
ie: "—", // Interlingue - International (Constructed Language)
|
||||||
|
ii: "CN", // Sichuan Yi - China
|
||||||
|
ik: "US", // Inupiaq - United States
|
||||||
|
io: "—", // Ido - International (Constructed Language)
|
||||||
|
iu: "CA", // Inuktitut - Canada
|
||||||
|
kg: "CG", // Kongo - Congo
|
||||||
|
ki: "KE", // Kikuyu - Kenya
|
||||||
|
kj: "AO", // Kuanyama - Angola
|
||||||
|
kk: "KZ", // Kazakh - Kazakhstan
|
||||||
|
kl: "GL", // Kalaallisut - Greenland
|
||||||
|
kr: "NE", // Kanuri - Niger
|
||||||
|
ks: "IN", // Kashmiri - India
|
||||||
|
kv: "RU", // Komi - Russia
|
||||||
|
kw: "GB", // Cornish - United Kingdom
|
||||||
|
la: "VA", // Latin - Vatican City
|
||||||
|
lb: "LU", // Luxembourgish - Luxembourg
|
||||||
|
lg: "UG", // Ganda - Uganda
|
||||||
|
li: "NL", // Limburgish - Netherlands
|
||||||
|
lu: "CD", // Luba-Katanga - Democratic Republic of the Congo
|
||||||
|
mh: "MH", // Marshallese - Marshall Islands
|
||||||
|
mi: "NZ", // Maori - New Zealand
|
||||||
|
na: "NR", // Nauru - Nauru
|
||||||
|
nb: "NO", // Norwegian Bokmål - Norway
|
||||||
|
nd: "ZW", // North Ndebele - Zimbabwe
|
||||||
|
ng: "NA", // Ndonga - Namibia
|
||||||
|
nn: "NO", // Norwegian Nynorsk - Norway
|
||||||
|
nr: "ZA", // South Ndebele - South Africa
|
||||||
|
nv: "US", // Navajo - United States
|
||||||
|
oc: "FR", // Occitan - France
|
||||||
|
oj: "CA", // Ojibwe - Canada
|
||||||
|
om: "ET", // Oromo - Ethiopia
|
||||||
|
os: "GE", // Ossetian - Georgia
|
||||||
|
pi: "IN", // Pali - India
|
||||||
|
qu: "PE", // Quechua - Peru
|
||||||
|
rm: "CH", // Romansh - Switzerland
|
||||||
|
rn: "BI", // Rundi - Burundi
|
||||||
|
sa: "IN", // Sanskrit - India
|
||||||
|
sc: "IT", // Sardinian - Italy
|
||||||
|
se: "NO", // Northern Sami - Norway
|
||||||
|
sg: "CF", // Sango - Central African Republic
|
||||||
|
sm: "WS", // Samoan - Samoa
|
||||||
|
sn: "ZW", // Shona - Zimbabwe
|
||||||
|
ss: "SZ", // Swati - Eswatini
|
||||||
|
st: "LS", // Southern Sotho - Lesotho
|
||||||
|
tn: "BW", // Tswana - Botswana
|
||||||
|
to: "TO", // Tonga - Tonga
|
||||||
|
ts: "ZA", // Tsonga - South Africa
|
||||||
|
tt: "RU", // Tatar - Russia
|
||||||
|
tw: "GH", // Twi - Ghana
|
||||||
|
ty: "PF", // Tahitian - French Polynesia
|
||||||
|
ug: "CN", // Uyghur - China
|
||||||
|
ve: "ZA", // Venda - South Africa
|
||||||
|
vo: "—", // Volapük - International (Constructed Language)
|
||||||
|
wa: "BE", // Walloon - Belgium
|
||||||
|
wo: "SN", // Wolof - Senegal
|
||||||
|
yi: "—", // Yiddish - International (Primarily spoken among Jewish communities)
|
||||||
|
za: "CN", // Zhuang - China
|
||||||
|
};
|
||||||
|
32
pnpm-lock.yaml
generated
32
pnpm-lock.yaml
generated
@@ -5191,7 +5191,7 @@ packages:
|
|||||||
'@typescript-eslint/type-utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3)
|
'@typescript-eslint/type-utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3)
|
||||||
'@typescript-eslint/utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3)
|
'@typescript-eslint/utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3)
|
||||||
'@typescript-eslint/visitor-keys': 6.20.0
|
'@typescript-eslint/visitor-keys': 6.20.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
eslint: 8.56.0
|
eslint: 8.56.0
|
||||||
graphemer: 1.4.0
|
graphemer: 1.4.0
|
||||||
ignore: 5.3.1
|
ignore: 5.3.1
|
||||||
@@ -5217,7 +5217,7 @@ packages:
|
|||||||
'@typescript-eslint/types': 6.20.0
|
'@typescript-eslint/types': 6.20.0
|
||||||
'@typescript-eslint/typescript-estree': 6.20.0(typescript@5.3.3)
|
'@typescript-eslint/typescript-estree': 6.20.0(typescript@5.3.3)
|
||||||
'@typescript-eslint/visitor-keys': 6.20.0
|
'@typescript-eslint/visitor-keys': 6.20.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
eslint: 8.56.0
|
eslint: 8.56.0
|
||||||
typescript: 5.3.3
|
typescript: 5.3.3
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
@@ -5243,7 +5243,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@typescript-eslint/typescript-estree': 6.20.0(typescript@5.3.3)
|
'@typescript-eslint/typescript-estree': 6.20.0(typescript@5.3.3)
|
||||||
'@typescript-eslint/utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3)
|
'@typescript-eslint/utils': 6.20.0(eslint@8.56.0)(typescript@5.3.3)
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
eslint: 8.56.0
|
eslint: 8.56.0
|
||||||
ts-api-utils: 1.0.3(typescript@5.3.3)
|
ts-api-utils: 1.0.3(typescript@5.3.3)
|
||||||
typescript: 5.3.3
|
typescript: 5.3.3
|
||||||
@@ -5389,7 +5389,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==}
|
resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==}
|
||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
@@ -6753,6 +6753,18 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ms: 2.1.2
|
ms: 2.1.2
|
||||||
|
|
||||||
|
/debug@4.3.4(supports-color@5.5.0):
|
||||||
|
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
|
||||||
|
engines: {node: '>=6.0'}
|
||||||
|
peerDependencies:
|
||||||
|
supports-color: '*'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
supports-color:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
ms: 2.1.2
|
||||||
|
supports-color: 5.5.0
|
||||||
|
|
||||||
/decamelize@1.2.0:
|
/decamelize@1.2.0:
|
||||||
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
|
resolution: {integrity: sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@@ -8227,7 +8239,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
basic-ftp: 5.0.4
|
basic-ftp: 5.0.4
|
||||||
data-uri-to-buffer: 6.0.1
|
data-uri-to-buffer: 6.0.1
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
fs-extra: 8.1.0
|
fs-extra: 8.1.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
@@ -8548,7 +8560,7 @@ packages:
|
|||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
agent-base: 7.1.0
|
agent-base: 7.1.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
@@ -8568,7 +8580,7 @@ packages:
|
|||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
agent-base: 7.1.0
|
agent-base: 7.1.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
@@ -10672,7 +10684,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tootallnate/quickjs-emscripten': 0.23.0
|
'@tootallnate/quickjs-emscripten': 0.23.0
|
||||||
agent-base: 7.1.0
|
agent-base: 7.1.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
get-uri: 6.0.2
|
get-uri: 6.0.2
|
||||||
http-proxy-agent: 7.0.0
|
http-proxy-agent: 7.0.0
|
||||||
https-proxy-agent: 7.0.2
|
https-proxy-agent: 7.0.2
|
||||||
@@ -11119,7 +11131,7 @@ packages:
|
|||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
agent-base: 7.1.0
|
agent-base: 7.1.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
http-proxy-agent: 7.0.0
|
http-proxy-agent: 7.0.0
|
||||||
https-proxy-agent: 7.0.2
|
https-proxy-agent: 7.0.2
|
||||||
lru-cache: 7.18.3
|
lru-cache: 7.18.3
|
||||||
@@ -12243,7 +12255,7 @@ packages:
|
|||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
dependencies:
|
dependencies:
|
||||||
agent-base: 7.1.0
|
agent-base: 7.1.0
|
||||||
debug: 4.3.4
|
debug: 4.3.4(supports-color@5.5.0)
|
||||||
socks: 2.7.1
|
socks: 2.7.1
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
Reference in New Issue
Block a user