1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

attempts to enable localization in webpack config, reverted screenshot.png

This commit is contained in:
Roman 2020-06-10 17:51:11 +03:00
parent 54b7edfb51
commit 725e0734fd
13 changed files with 4462 additions and 1970 deletions

View File

@ -1,10 +1,10 @@
{ {
"plugins": [
"macros",
"@babel/plugin-transform-runtime"
],
"presets": [ "presets": [
"@babel/preset-env", "@babel/preset-env",
"@babel/preset-react" "@babel/preset-react",
"@lingui/babel-preset-react"
],
"plugins": [
"macros"
] ]
} }

BIN
.github/screenshot.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 KiB

View File

@ -4,7 +4,7 @@
Lens is the only IDE youll ever need to take control of your Kubernetes clusters. It is a standalone application for MacOS, Windows and Linux operating systems. It is open source and free. Lens is the only IDE youll ever need to take control of your Kubernetes clusters. It is a standalone application for MacOS, Windows and Linux operating systems. It is open source and free.
[![Screenshot](./images/screenshot.png)](https://youtu.be/04v2ODsmtIs) [![Screenshot](.github/screenshot.png)](https://youtu.be/04v2ODsmtIs)
## What makes Lens special? ## What makes Lens special?

View File

@ -47,16 +47,15 @@
} }
}, },
"lingui": { "lingui": {
"locales": ["en", "ru"], "locales": [
"en",
"ru",
"fi"
],
"sourceLocale": "en", "sourceLocale": "en",
"fallbackLocale": "en", "fallbackLocale": "en",
"compileNamespace": "cjs", "compileNamespace": "es",
"format": "po", "format": "po",
"extractBabelOptions": {
"plugins": [
"@babel/plugin-syntax-dynamic-import"
]
},
"catalogs": [ "catalogs": [
{ {
"path": "./src/locales/{locale}/messages", "path": "./src/locales/{locale}/messages",
@ -170,7 +169,7 @@
"@types/proper-lockfile": "^4.1.1", "@types/proper-lockfile": "^4.1.1",
"@types/tar": "^4.0.3", "@types/tar": "^4.0.3",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"electron": "^9.0.2", "electron": "^6.1.12",
"electron-promise-ipc": "^2.1.0", "electron-promise-ipc": "^2.1.0",
"electron-store": "^5.2.0", "electron-store": "^5.2.0",
"electron-updater": "^4.3.1", "electron-updater": "^4.3.1",
@ -205,11 +204,10 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.10.2", "@babel/core": "^7.10.2",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/preset-env": "^7.10.2", "@babel/preset-env": "^7.10.2",
"@babel/preset-react": "^7.10.1", "@babel/preset-react": "^7.10.1",
"@babel/preset-typescript": "^7.10.1", "@babel/preset-typescript": "^7.10.1",
"@lingui/babel-preset-react": "^2.9.1",
"@lingui/cli": "^3.0.0-13", "@lingui/cli": "^3.0.0-13",
"@lingui/loader": "^3.0.0-13", "@lingui/loader": "^3.0.0-13",
"@lingui/macro": "^3.0.0-13", "@lingui/macro": "^3.0.0-13",

File diff suppressed because it is too large Load Diff

2466
src/locales/fi/messages.po Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,8 @@ export class App extends React.Component {
static rootElem = document.getElementById('app'); static rootElem = document.getElementById('app');
static async init() { static async init() {
await i18nStore.init(); // await i18nStore.init();
await configStore.init(); // await configStore.init();
render(<App/>, App.rootElem); render(<App/>, App.rootElem);
}; };

View File

@ -42,7 +42,7 @@ export class ConfigStore {
} }
get allowedResources() { get allowedResources() {
return this.config.allowedResources; return this.config.allowedResources || [];
} }
get isClusterAdmin() { get isClusterAdmin() {

View File

@ -22,10 +22,11 @@ export class LocalizationStore {
readonly defaultLocale = "en" readonly defaultLocale = "en"
@observable activeLang = this.defaultLocale; @observable activeLang = this.defaultLocale;
// todo: verify with package.json ling-ui "locales"
public languages: ILanguage[] = orderBy<ILanguage>([ public languages: ILanguage[] = orderBy<ILanguage>([
{ code: "en", title: "English", nativeTitle: "English" }, { code: "en", title: "English", nativeTitle: "English" },
{ code: "ru", title: "Russian", nativeTitle: "Русский" }, { code: "ru", title: "Russian", nativeTitle: "Русский" },
// { code: "fi", title: "Finnish", nativeTitle: "Suomi" }, { code: "fi", title: "Finnish", nativeTitle: "Suomi" },
], "title"); ], "title");
constructor() { constructor() {
@ -39,10 +40,7 @@ export class LocalizationStore {
} }
async load(locale: string) { async load(locale: string) {
const catalog = await import( const catalog = await import(`../locales/${locale}/messages.po`);
/* webpackMode: "lazy", webpackChunkName: "locale/[request]" */
`@lingui/loader!../locales/${locale}/messages.po`
);
return _i18n.load(locale, catalog); return _i18n.load(locale, catalog);
} }

View File

@ -4,32 +4,46 @@ const path = require("path");
module.exports = function (config, env) { module.exports = function (config, env) {
const {rules} = config.module; const {rules} = config.module;
// patch-fix sass-loader // localization support
const sassLoaderName = "sass-loader"; // https://lingui.js.org/guides/typescript.html
const sassLoaderRule = rules.find(rule => { rules.push({
if (Array.isArray(rule.use)) return rule.use.includes(sassLoaderName) test: /\.po$/,
return rule.use === sassLoaderName; use: '@lingui/loader'
}); });
if (sassLoaderRule) { patchLoader(".tsx", "ts-loader", loader => {
let index = sassLoaderRule.use.findIndex(loader => loader === sassLoaderName); loader.options = Object.assign({}, loader.options, {
sassLoaderRule.use[index] = { compilerOptions: {
loader: sassLoaderName, jsx: "preserve",
options: { target: "es2016",
prependData: '@import "vars.scss";',
sassOptions: {
includePaths: [
path.resolve(__dirname, "components")
]
}
} }
})
return ["babel-loader", loader]
});
// sass common vars file import
patchLoader(".scss", "sass-loader", loader => {
loader.options = Object.assign({}, loader.options, {
prependData: '@import "vars.scss";',
sassOptions: {
includePaths: [
path.resolve(__dirname, "components")
]
}
})
return loader;
});
function patchLoader(fileType, loaderName, updater) {
let rule = rules.find(rule => fileType.match(rule.test));
if (rule) {
let loaders = [rule.use].flat();
let index = loaders.findIndex(loader => loader === loaderName || loader.loader === loaderName);
let loader = typeof loaders[index] === "string" ? {loader: loaders[index]} : loaders[index];
loaders[index] = updater(loader);
rule.use = loaders.flat();
console.info(`Patched renderer's webpack loader "${loaderName}"`);
} }
} }
// add inline svg icons support
rules.push({
test: /\.txt$/,
use: 'raw-loader'
});
return config; return config;
} }

View File

@ -4,8 +4,6 @@
"baseUrl": ".", "baseUrl": ".",
"outDir": "./dist", "outDir": "./dist",
"jsx": "react", "jsx": "react",
"target": "ES2017",
"module": "CommonJS",
"lib": ["ESNext", "DOM", "DOM.Iterable"], "lib": ["ESNext", "DOM", "DOM.Iterable"],
"moduleResolution": "Node", "moduleResolution": "Node",
"sourceMap": true, "sourceMap": true,

View File

@ -729,16 +729,6 @@
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.10.1" "@babel/helper-plugin-utils" "^7.10.1"
"@babel/plugin-transform-runtime@^7.10.1":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.10.1.tgz#fd1887f749637fb2ed86dc278e79eb41df37f4b1"
integrity sha512-4w2tcglDVEwXJ5qxsY++DgWQdNJcCCsPxfT34wCUwIf2E7dI7pMpH8JczkMBbgBTNzBX62SZlNJ9H+De6Zebaw==
dependencies:
"@babel/helper-module-imports" "^7.10.1"
"@babel/helper-plugin-utils" "^7.10.1"
resolve "^1.8.1"
semver "^5.5.1"
"@babel/plugin-transform-shorthand-properties@^7.10.1": "@babel/plugin-transform-shorthand-properties@^7.10.1":
version "7.10.1" version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.10.1.tgz#e8b54f238a1ccbae482c4dce946180ae7b3143f3" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.10.1.tgz#e8b54f238a1ccbae482c4dce946180ae7b3143f3"
@ -1395,6 +1385,24 @@
"@lingui/conf" "3.0.0-13" "@lingui/conf" "3.0.0-13"
mkdirp "^1.0.4" mkdirp "^1.0.4"
"@lingui/babel-plugin-transform-js@2.9.1":
version "2.9.1"
resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-transform-js/-/babel-plugin-transform-js-2.9.1.tgz#64ff5e0fe7c1a1714ec6173a3e3ebc7e3253fd55"
integrity sha512-m1RAKUKffyxfWQ2Y0KfGHhYofdHdM+0aSsi2kgcebqzsuE8Hwuy+r4GZr593cSIqBu6Ugb6/WKoAUGUoEF9ZHw==
"@lingui/babel-plugin-transform-react@2.9.1":
version "2.9.1"
resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-transform-react/-/babel-plugin-transform-react-2.9.1.tgz#9e6a9da4cb3d3226aafd8f856f6025646d4e409f"
integrity sha512-3btgAUpH5OSlZf/c4bXsDtvPity+H+7Mm1GJmWEwQSjl5kQNLisNVHpWPKvESuNbfQEtmtK5iIMVUYx8GD/Sig==
"@lingui/babel-preset-react@^2.9.1":
version "2.9.1"
resolved "https://registry.yarnpkg.com/@lingui/babel-preset-react/-/babel-preset-react-2.9.1.tgz#1c71970578eb4048f863e42057a0bcb56c949a23"
integrity sha512-cCviQe7rhuJUShJ6zhM2ZttbelaJRRnZ6efwo0xAatcnQ5E8rKdpCAj0YH2bePsLZT1MfaPz1t9d2hMYaIRW2g==
dependencies:
"@lingui/babel-plugin-transform-js" "2.9.1"
"@lingui/babel-plugin-transform-react" "2.9.1"
"@lingui/cli@3.0.0-13", "@lingui/cli@^3.0.0-13": "@lingui/cli@3.0.0-13", "@lingui/cli@^3.0.0-13":
version "3.0.0-13" version "3.0.0-13"
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.0.0-13.tgz#ffe019079823b7e1760850e46a660582a449ee7c" resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.0.0-13.tgz#ffe019079823b7e1760850e46a660582a449ee7c"
@ -1918,6 +1926,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.24.tgz#c57511e3a19c4b5e9692bb2995c40a3a52167944" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.24.tgz#c57511e3a19c4b5e9692bb2995c40a3a52167944"
integrity sha512-5SCfvCxV74kzR3uWgTYiGxrd69TbT1I6+cMx1A5kEly/IVveJBimtAMlXiEyVFn5DvUFewQWxOOiJhlxeQwxgA== integrity sha512-5SCfvCxV74kzR3uWgTYiGxrd69TbT1I6+cMx1A5kEly/IVveJBimtAMlXiEyVFn5DvUFewQWxOOiJhlxeQwxgA==
"@types/node@^10.12.18":
version "10.17.26"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.26.tgz#a8a119960bff16b823be4c617da028570779bcfd"
integrity sha512-myMwkO2Cr82kirHY8uknNRHEVtn0wV3DTQfkrjx17jmkstDRZ24gNUdl8AHXVyVclTYI/bNjgTPTAWvWLqXqkw==
"@types/node@^12.0.12": "@types/node@^12.0.12":
version "12.12.44" version "12.12.44"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.44.tgz#0d400a1453adcb359b133acceae4dd8bb0e0a159" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.44.tgz#0d400a1453adcb359b133acceae4dd8bb0e0a159"
@ -4807,7 +4820,7 @@ electron-devtools-installer@^2.2.4:
rimraf "^2.5.2" rimraf "^2.5.2"
semver "^5.3.0" semver "^5.3.0"
electron-download@^4.1.1: electron-download@^4.1.0, electron-download@^4.1.1:
version "4.1.1" version "4.1.1"
resolved "https://registry.yarnpkg.com/electron-download/-/electron-download-4.1.1.tgz#02e69556705cc456e520f9e035556ed5a015ebe8" resolved "https://registry.yarnpkg.com/electron-download/-/electron-download-4.1.1.tgz#02e69556705cc456e520f9e035556ed5a015ebe8"
integrity sha512-FjEWG9Jb/ppK/2zToP+U5dds114fM1ZOJqMAR4aXXL5CvyPE9fiqBK/9YcwC9poIFQTEJk/EM/zyRwziziRZrg== integrity sha512-FjEWG9Jb/ppK/2zToP+U5dds114fM1ZOJqMAR4aXXL5CvyPE9fiqBK/9YcwC9poIFQTEJk/EM/zyRwziziRZrg==
@ -4942,7 +4955,7 @@ electron-window-state@^5.0.3:
jsonfile "^4.0.0" jsonfile "^4.0.0"
mkdirp "^0.5.1" mkdirp "^0.5.1"
electron@*, electron@^9.0.2: electron@*:
version "9.0.2" version "9.0.2"
resolved "https://registry.yarnpkg.com/electron/-/electron-9.0.2.tgz#361924ce833396f1a45ac2195f442b92eb4f8f5d" resolved "https://registry.yarnpkg.com/electron/-/electron-9.0.2.tgz#361924ce833396f1a45ac2195f442b92eb4f8f5d"
integrity sha512-+a3KegLvQXVjC3b6yBWwZmtWp3tHf9ut27yORAWHO9JRFtKfNf88fi1UvTPJSW8R0sUH7ZEdzN6A95T22KGtlA== integrity sha512-+a3KegLvQXVjC3b6yBWwZmtWp3tHf9ut27yORAWHO9JRFtKfNf88fi1UvTPJSW8R0sUH7ZEdzN6A95T22KGtlA==
@ -4951,6 +4964,15 @@ electron@*, electron@^9.0.2:
"@types/node" "^12.0.12" "@types/node" "^12.0.12"
extract-zip "^1.0.3" extract-zip "^1.0.3"
electron@^6.1.12:
version "6.1.12"
resolved "https://registry.yarnpkg.com/electron/-/electron-6.1.12.tgz#a7aee6dfa75b57f32b3645ef8e14dcef6d5f31a9"
integrity sha512-RUPM8xJfTcm53V9EKMBhvpLu1+CQkmuvWDmVCypR5XbUG1OOrOLiKl0CqUZ9+tEDuOmC+DmzmJP2MZXScBU5IA==
dependencies:
"@types/node" "^10.12.18"
electron-download "^4.1.0"
extract-zip "^1.0.3"
elliptic@^6.0.0, elliptic@^6.5.2: elliptic@^6.0.0, elliptic@^6.5.2:
version "6.5.2" version "6.5.2"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.2.tgz#05c5678d7173c049d8ca433552224a495d0e3762" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.2.tgz#05c5678d7173c049d8ca433552224a495d0e3762"
@ -10285,7 +10307,7 @@ resolve-url@^0.2.1:
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=
resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.17.0, resolve@^1.3.2, resolve@^1.8.1: resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.17.0, resolve@^1.3.2:
version "1.17.0" version "1.17.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444"
integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==
@ -10545,7 +10567,7 @@ semver-diff@^3.1.1:
dependencies: dependencies:
semver "^6.3.0" semver "^6.3.0"
"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0: "semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0:
version "5.7.1" version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==