From 26611526735f3dbc3b51331c739eee95de184155 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Fri, 9 Aug 2024 10:41:54 +0200 Subject: [PATCH] - added i18n internationalization; --- .babelrc | 3 ++- package-lock.json | 25 ++++++++++++++++++--- package.json | 1 + {languages => public/languages}/en_US.json | 2 +- {languages => public/languages}/gepafin.pot | 0 src/App.js | 15 ++++++------- yarn.lock | 14 ++++++++++-- 7 files changed, 45 insertions(+), 15 deletions(-) rename {languages => public/languages}/en_US.json (86%) rename {languages => public/languages}/gepafin.pot (100%) diff --git a/.babelrc b/.babelrc index 57ed39b..442fa2f 100644 --- a/.babelrc +++ b/.babelrc @@ -7,6 +7,7 @@ "domain": "gepafin" } ], - "@babel/plugin-syntax-jsx" + "@babel/plugin-syntax-jsx", + "@babel/plugin-proposal-private-property-in-object" ] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index eaf9a58..33fcc8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "bflows-gepafin", "version": "1.0.0", "dependencies": { + "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/preset-react": "^7.24.7", "@emotion/react": "11.13.0", "@emotion/styled": "11.13.0", @@ -630,9 +631,16 @@ } }, "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0-placeholder-for-preset-env.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", - "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "version": "7.21.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz", + "integrity": "sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw==", + "deprecated": "This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-private-property-in-object instead.", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.18.6", + "@babel/helper-create-class-features-plugin": "^7.21.0", + "@babel/helper-plugin-utils": "^7.20.2", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, "engines": { "node": ">=6.9.0" }, @@ -1883,6 +1891,17 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/preset-env/node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.0-placeholder-for-preset-env.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", + "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/preset-modules": { "version": "0.1.6-no-external-plugins", "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz", diff --git a/package.json b/package.json index 9cc487c..840486b 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "private": true, "dependencies": { + "@babel/plugin-proposal-private-property-in-object": "^7.21.11", "@babel/preset-react": "^7.24.7", "@emotion/react": "11.13.0", "@emotion/styled": "11.13.0", diff --git a/languages/en_US.json b/public/languages/en_US.json similarity index 86% rename from languages/en_US.json rename to public/languages/en_US.json index b12940c..e96a081 100644 --- a/languages/en_US.json +++ b/public/languages/en_US.json @@ -6,7 +6,7 @@ "domain": "gepafin" }, "Login page": [ - "Login111 page" + "Auth page" ] } } diff --git a/languages/gepafin.pot b/public/languages/gepafin.pot similarity index 100% rename from languages/gepafin.pot rename to public/languages/gepafin.pot diff --git a/src/App.js b/src/App.js index 3a2d5ee..b0de2a4 100644 --- a/src/App.js +++ b/src/App.js @@ -1,21 +1,20 @@ -import { useState, useEffect } from 'react'; +import { useEffect } from 'react'; import { BrowserRouter } from 'react-router-dom'; import Routes from './routes'; import { createI18n, setLocaleData } from '@wordpress/i18n'; import { I18nProvider } from '@wordpress/react-i18n'; -const i18n = createI18n(); +const i18n = createI18n({}, 'gepafin'); function App() { - const [messages, setMessages] = useState({}); - + console.log('mount') useEffect(() => { - /*import('../languages/en_US.json').then((translations) => { - setLocaleData(translations, 'gepafin'); - });*/ fetch('/languages/en_US.json') .then((res) => res.json()) - .then(res => console.log(res)) + .then(res => { + console.log('loaded') + setLocaleData(res.locale_data['gepafin'], 'gepafin') + }) }, []); return ( diff --git a/yarn.lock b/yarn.lock index b297f3e..985c637 100644 --- a/yarn.lock +++ b/yarn.lock @@ -93,7 +93,7 @@ "@jridgewell/trace-mapping" "^0.3.25" jsesc "^2.5.1" -"@babel/helper-annotate-as-pure@^7.24.7": +"@babel/helper-annotate-as-pure@^7.18.6", "@babel/helper-annotate-as-pure@^7.24.7": version "7.24.7" resolved "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.24.7.tgz" integrity sha512-BaDeOonYvhdKw+JoMVkAixAAJzG2jVPIwWoKBPdYuY9b452e2rPuI9QPYh3KpofZ3pW2akOmwZLOiOsHMiqRAg== @@ -119,7 +119,7 @@ lru-cache "^5.1.1" semver "^6.3.1" -"@babel/helper-create-class-features-plugin@^7.18.6", "@babel/helper-create-class-features-plugin@^7.24.7", "@babel/helper-create-class-features-plugin@^7.25.0": +"@babel/helper-create-class-features-plugin@^7.18.6", "@babel/helper-create-class-features-plugin@^7.21.0", "@babel/helper-create-class-features-plugin@^7.24.7", "@babel/helper-create-class-features-plugin@^7.25.0": version "7.25.0" resolved "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.25.0.tgz" integrity sha512-GYM6BxeQsETc9mnct+nIIpf63SAyzvyYN7UB/IlTyd+MBg06afFGp0mIeUqGyWgS2mxad6vqbMrHVlaL3m70sQ== @@ -362,6 +362,16 @@ "@babel/helper-create-class-features-plugin" "^7.18.6" "@babel/helper-plugin-utils" "^7.18.6" +"@babel/plugin-proposal-private-property-in-object@^7.21.11": + version "7.21.11" + resolved "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.11.tgz" + integrity sha512-0QZ8qP/3RLDVBwBFoWAwCtgcDZJVwA5LUJRZU8x2YFfKNuFq161wK3cuGrALu5yiPu+vzwTAg/sMWVNeWeNyaw== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-create-class-features-plugin" "^7.21.0" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-private-property-in-object" "^7.14.5" + "@babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2": version "7.21.0-placeholder-for-preset-env.2" resolved "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz"