Skip to content

Commit

Permalink
feat(locales): add finnish language
Browse files Browse the repository at this point in the history
  • Loading branch information
rhahao committed Oct 19, 2024
1 parent 78157dd commit da6de97
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/browser/utils.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import CH from '../locales/cmn-Hant/text.json';
import CHS from '../locales/ch-CHS/text.json';
import E from '../locales/en/text.json';
import F from '../locales/fr-FR/text.json';
import FI from '../locales/fi-FI/text.json';
import I from '../locales/it-IT/text.json';
import J from '../locales/ja-JP/text.json';
import K from '../locales/uk-UA/text.json';
Expand Down Expand Up @@ -31,6 +32,6 @@ declare global {
}

window.jw_epub_parser = {
languages: { CH, CHS, E, F, I, J, K, KO, M, MG, P, S, T, TG, TK, TND, TNK, TPO, TTM, TW, U, VZ, X },
languages: { CH, CHS, E, F, FI, I, J, K, KO, M, MG, P, S, T, TG, TK, TND, TNK, TPO, TTM, TW, U, VZ, X },
path: path,
};
8 changes: 8 additions & 0 deletions src/common/date_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const mwbDatePatterns: LangRegExp = {
CH: new RegExp(mwbDatePatternJ, 'giu'),
CHS: new RegExp(mwbDatePatternJ, 'giu'),
E: new RegExp(mwbDatePatternE, 'giu'),
FI: new RegExp(mwbDatePatternX, 'giu'),
J: new RegExp(mwbDatePatternJ, 'giu'),
KO: new RegExp(mwbDatePatternKO, 'giu'),
P: new RegExp(mwbDatePatternP, 'giu'),
Expand Down Expand Up @@ -230,11 +231,18 @@ option1 = `(\\d{1,2}). bis (?:\\d{1,2}).? (${wordWithDiacritics}) (\\d{4})`;
option2 = `(\\d{1,2}). (${wordWithDiacritics}) (\\d{4})`;
const wDatePatternX = `${option1}|${option2}`;

// date like 1-) Tutkitaan 3.–9.2.2025 ; or 2) Tutkitaan 24.2.–2.3.2025. ; or 3) Tutkitaan 30.12.2024–5.1.2025.
option1 = '(\\d{1,2}).[–](?:\\d{1,2}).(\\d{1,2}).(\\d{4})';
option2 = '(\\d{1,2}).(\\d{1,2}).[–](?:\\d{1,2}).(?:\\d{1,2}).(\\d{4})';
option3 = '(\\d{1,2}).(\\d{1,2}).(\\d{4})';
const wDatePatternFI = `${option1}|${option2}|${option3}`;

const wDatePatterns: LangRegExp = {
common: new RegExp(wDatePatternCommon, 'giu'),
CH: new RegExp(wDatePatternJ, 'giu'),
CHS: new RegExp(wDatePatternJ, 'giu'),
E: new RegExp(wDatePatternE, 'giu'),
FI: new RegExp(wDatePatternFI, 'giu'),
J: new RegExp(wDatePatternJ, 'giu'),
KO: new RegExp(wDatePatternKO, 'giu'),
P: new RegExp(wDatePatternP, 'giu'),
Expand Down
48 changes: 25 additions & 23 deletions src/locales/languages.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
export default [
{ locale: 'en', code: 'E' },
{ locale: 'fr-FR', code: 'F' },
{ locale: 'it-IT', code: 'I' },
{ locale: 'ja-JP', code: 'J' },
{ locale: 'uk-UA', code: 'K' },
{ locale: 'ko-KR', code: 'KO' },
{ locale: 'ro-RO', code: 'M' },
{ locale: 'mg-MG', code: 'MG' },
{ locale: 'pl-PL', code: 'P' },
{ locale: 'es-ES', code: 'S' },
{ locale: 'pt-BR', code: 'T' },
{ locale: 'pt-PT', code: 'TPO'},
{ locale: 'tl-PH', code: 'TG' },
{ locale: 'tr-TR', code: 'TK' },
{ locale: 'mg-TND', code: 'TND' },
{ locale: 'mg-TNK', code: 'TNK' },
{ locale: 'mg-TTM', code: 'TTM' },
{ locale: 'tw-TW', code: 'TW' },
{ locale: 'uk-UA', code: 'U' },
{ locale: 'mg-VZ', code: 'VZ' },
{ locale: 'de-DE', code: 'X' },
{ locale: 'cmn-Hant', code: 'CH' },
{ locale: 'ch-CHS', code: 'CHS' },
{ locale: 'en', code: 'E' },
{ locale: 'fr-FR', code: 'F' },
{ locale: 'it-IT', code: 'I' },
{ locale: 'ja-JP', code: 'J' },
{ locale: 'uk-UA', code: 'K' },
{ locale: 'ko-KR', code: 'KO' },
{ locale: 'ro-RO', code: 'M' },
{ locale: 'mg-MG', code: 'MG' },
{ locale: 'pl-PL', code: 'P' },
{ locale: 'es-ES', code: 'S' },
{ locale: 'pt-BR', code: 'T' },
{ locale: 'pt-PT', code: 'TPO' },
{ locale: 'tl-PH', code: 'TG' },
{ locale: 'tr-TR', code: 'TK' },
{ locale: 'mg-TND', code: 'TND' },
{ locale: 'mg-TNK', code: 'TNK' },
{ locale: 'mg-TTM', code: 'TTM' },
{ locale: 'tw-TW', code: 'TW' },
{ locale: 'uk-UA', code: 'U' },
{ locale: 'mg-VZ', code: 'VZ' },
{ locale: 'de-DE', code: 'X' },
{ locale: 'cmn-Hant', code: 'CH' },
{ locale: 'ch-CHS', code: 'CHS' },
{ locale: 'fi-FI', code: 'FI' },
{ locale: 'sv-SE', code: 'Z' },
];
3 changes: 2 additions & 1 deletion src/node/utils.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import CH from '../locales/cmn-Hant/text.json' assert { type: 'json' };
import CHS from '../locales/ch-CHS/text.json' assert { type: 'json' };
import E from '../locales/en/text.json' assert { type: 'json' };
import F from '../locales/fr-FR/text.json' assert { type: 'json' };
import FI from '../locales/fi-FI/text.json' assert { type: 'json' };
import I from '../locales/it-IT/text.json' assert { type: 'json' };
import J from '../locales/ja-JP/text.json' assert { type: 'json' };
import K from '../locales/uk-UA/text.json' assert { type: 'json' };
Expand All @@ -30,7 +31,7 @@ declare global {
}

global.jw_epub_parser = {
languages: { CH, CHS, E, F, I, J, K, KO, M, MG, P, S, T, TG, TK, TND, TNK, TPO, TTM, TW, U, VZ, X },
languages: { CH, CHS, E, F, FI, I, J, K, KO, M, MG, P, S, T, TG, TK, TND, TNK, TPO, TTM, TW, U, VZ, X },
path: path,
readFile: readFile,
};

0 comments on commit da6de97

Please sign in to comment.