go on with i18n

This commit is contained in:
Matteo Manzinello 2020-06-10 19:40:55 +02:00
parent 13e8e9e828
commit 01fc4f1447
6 changed files with 18 additions and 5 deletions

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,12 @@ function js() {
.pipe(replace(MAILGO_STYLE_TAG, cssMinContent)) .pipe(replace(MAILGO_STYLE_TAG, cssMinContent))
.pipe(tsProject()) .pipe(tsProject())
// .pipe(babel()) // .pipe(babel())
.pipe(dest("./")) .pipe(
rename({
suffix: ".m",
})
)
.pipe(dest("src"))
); );
} }

View File

@ -10,8 +10,8 @@
"type": "git", "type": "git",
"url": "git+https://github.com/manzinello/mailgo.git" "url": "git+https://github.com/manzinello/mailgo.git"
}, },
"main": "./mailgo.js", "main": "./mailgo.m.js",
"module": "./mailgo.js", "module": "./mailgo.m.js",
"keywords": [ "keywords": [
"mailto", "mailto",
"mail", "mail",

View File

@ -35,6 +35,9 @@ const mailgoInit = (mailgoConfig) => {
i18n.languages.includes(mailgoConfig.defaultLang)) { i18n.languages.includes(mailgoConfig.defaultLang)) {
lang = mailgoConfig.defaultLang; lang = mailgoConfig.defaultLang;
} }
if (!mailgoConfig.forceLang) {
lang = document.documentElement.lang;
}
// strings // strings
let strings = translations[lang]; let strings = translations[lang];
// mailgo mail // mailgo mail

View File

@ -1,5 +1,5 @@
// import mailgo // import mailgo
import mailgo from "../mailgo"; import mailgo from "./mailgo.m.js";
// call init mailgo attached to the event DOMContentLoaded // call init mailgo attached to the event DOMContentLoaded

View File

@ -78,6 +78,11 @@ const mailgoInit = (mailgoConfig?: MailgoConfig): void => {
lang = mailgoConfig.defaultLang; lang = mailgoConfig.defaultLang;
} }
// if is defined <html lang=""> use it!
if (!mailgoConfig.forceLang && document.documentElement.lang) {
lang = document.documentElement.lang;
}
// strings // strings
let strings: any = translations[lang]; let strings: any = translations[lang];