mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-06 00:44:57 +05:30
Merge 0f460d81a1 into d22b7e56eb
This commit is contained in:
commit
e64f6ec2bb
3 changed files with 44 additions and 0 deletions
14
Dockerfile
14
Dockerfile
|
|
@ -10,12 +10,26 @@ RUN npm run build
|
||||||
|
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
ENV DEFAULT_LANG=en
|
||||||
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
RUN sed -i 's/application\/javascript.*js;/application\/javascript js mjs;/' /etc/nginx/mime.types
|
RUN sed -i 's/application\/javascript.*js;/application\/javascript js mjs;/' /etc/nginx/mime.types
|
||||||
|
|
||||||
RUN sed -i 's|index index.html index.htm;|index index.html index.htm;\n try_files $uri $uri/ /index.html;|' /etc/nginx/conf.d/default.conf
|
RUN sed -i 's|index index.html index.htm;|index index.html index.htm;\n try_files $uri $uri/ /index.html;|' /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
COPY <<'EOF' /docker-entrypoint.d/30-inject-default-lang.sh
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
find /usr/share/nginx/html -name "*.html" -exec sed -i \
|
||||||
|
"s|<head>|<head>\n <script>window.DEFAULT_LANG='${DEFAULT_LANG}';</script>|" {} \;
|
||||||
|
|
||||||
|
echo "Injected DEFAULT_LANG=${DEFAULT_LANG} into HTML files"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
RUN chmod +x /docker-entrypoint.d/30-inject-default-lang.sh
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
|
||||||
6
src/@types/i18n.d.ts
vendored
6
src/@types/i18n.d.ts
vendored
|
|
@ -31,3 +31,9 @@ declare module 'i18next' {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
DEFAULT_LANG?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,30 @@ export type FullI18nKey = {
|
||||||
[K in I18nNamespaces]: `${K}:${ParseKeys<K>}`;
|
[K in I18nNamespaces]: `${K}:${ParseKeys<K>}`;
|
||||||
}[I18nNamespaces];
|
}[I18nNamespaces];
|
||||||
|
|
||||||
|
const currentLang = localStorage.getItem('lang');
|
||||||
|
const userHasChosenLang = localStorage.getItem('userChosenLang'); // Flag to track if user manually selected
|
||||||
|
|
||||||
|
if (
|
||||||
|
window.DEFAULT_LANG &&
|
||||||
|
(!currentLang || (!userHasChosenLang && currentLang === 'en'))
|
||||||
|
) {
|
||||||
|
const supportedLangs = [
|
||||||
|
'en',
|
||||||
|
'de',
|
||||||
|
'es',
|
||||||
|
'fr',
|
||||||
|
'pt',
|
||||||
|
'ja',
|
||||||
|
'hi',
|
||||||
|
'nl',
|
||||||
|
'ru',
|
||||||
|
'zh'
|
||||||
|
];
|
||||||
|
if (supportedLangs.includes(window.DEFAULT_LANG)) {
|
||||||
|
localStorage.setItem('lang', window.DEFAULT_LANG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
i18n
|
i18n
|
||||||
.use(Backend)
|
.use(Backend)
|
||||||
.use(LanguageDetector)
|
.use(LanguageDetector)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue