Skip to content

Commit

Permalink
Merge pull request #4419 from James-Yu/4416-pdf-viewer-l10n-lang-variant
Browse files Browse the repository at this point in the history
Add pdf viewer l10n lang selector
  • Loading branch information
James-Yu authored Oct 2, 2024
2 parents 19080ab + a43bc9e commit e82fa06
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion viewer/components/l10n.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
export function getL10n(text: 'enableSyncTeX' | 'enableRefresh' | 'trimMargin' | 'navBack' | 'navForward'): string {
return l10n[text][navigator.language]
const keys = Object.keys(l10n[text])
const lang = navigator.language
if (keys.includes(lang)) {
return l10n[text][lang]
}
// A language variant
const key = keys.find(candidate => candidate.startsWith(lang))
if (key !== undefined) {
return l10n[text][key]
}
return l10n[text]['en-US']
}

const enableSyncTeX: {[lang: string]: string} = {
Expand Down

0 comments on commit e82fa06

Please sign in to comment.