Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
webinar_42
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulpybaev Ilyas
webinar_42
Commits
a1584923
Commit
a1584923
authored
Apr 04, 2024
by
Kulpybaev Ilyas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get dictionaries from api
parent
3979931e
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
248 additions
and
31 deletions
+248
-31
index.ts
backend/index.ts
+3
-0
translation.json
backend/locals/en/translation.json
+3
-0
translation.json
backend/locals/kz/translation.json
+3
-0
translation.json
backend/locals/ru/translation.json
+3
-0
package-lock.json
backend/package-lock.json
+56
-1
package.json
backend/package.json
+2
-1
package-lock.json
front/package-lock.json
+133
-1
package.json
front/package.json
+4
-1
App.tsx
front/src/App.tsx
+14
-27
translation.json
front/src/assets/locals/en/translation.json
+3
-0
translation.json
front/src/assets/locals/kz/translation.json
+3
-0
translation.json
front/src/assets/locals/ru/translation.json
+3
-0
i18n.ts
front/src/i18n.ts
+17
-0
main.tsx
front/src/main.tsx
+1
-0
No files found.
backend/index.ts
View file @
a1584923
import
express
from
'express'
;
import
cors
from
'cors'
;
import
path
from
'path'
;
const
PORT
=
8000
;
const
app
=
express
();
app
.
use
(
cors
());
app
.
use
(
'/locales'
,
express
.
static
(
path
.
join
(
__dirname
,
'locals'
)));
app
.
listen
(
PORT
);
console
.
log
(
'dev changes'
);
...
...
backend/locals/en/translation.json
0 → 100644
View file @
a1584923
{
"hi"
:
"hey"
}
\ No newline at end of file
backend/locals/kz/translation.json
0 → 100644
View file @
a1584923
{
"hi"
:
"salem"
}
\ No newline at end of file
backend/locals/ru/translation.json
0 → 100644
View file @
a1584923
{
"hi"
:
"privet"
}
\ No newline at end of file
backend/package-lock.json
View file @
a1584923
...
...
@@ -10,7 +10,8 @@
"license"
:
"ISC"
,
"dependencies"
:
{
"cors"
:
"^2.8.5"
,
"express"
:
"^4.19.2"
"express"
:
"^4.19.2"
,
"i18next-http-backend"
:
"^2.5.0"
},
"devDependencies"
:
{
"@types/cors"
:
"^2.8.17"
,
...
...
@@ -329,6 +330,14 @@
"integrity"
:
"sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ=="
,
"dev"
:
true
},
"node_modules/cross-fetch"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz"
,
"integrity"
:
"sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g=="
,
"dependencies"
:
{
"node-fetch"
:
"^2.6.12"
}
},
"node_modules/debug"
:
{
"version"
:
"2.6.9"
,
"resolved"
:
"https://registry.npmjs.org/debug/-/debug-2.6.9.tgz"
,
...
...
@@ -594,6 +603,14 @@
"node"
:
">= 0.8"
}
},
"node_modules/i18next-http-backend"
:
{
"version"
:
"2.5.0"
,
"resolved"
:
"https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-2.5.0.tgz"
,
"integrity"
:
"sha512-Z/aQsGZk1gSxt2/DztXk92DuDD20J+rNudT7ZCdTrNOiK8uQppfvdjq9+DFQfpAnFPn3VZS+KQIr1S/W1KxhpQ=="
,
"dependencies"
:
{
"cross-fetch"
:
"4.0.0"
}
},
"node_modules/iconv-lite"
:
{
"version"
:
"0.4.24"
,
"resolved"
:
"https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz"
,
...
...
@@ -688,6 +705,25 @@
"node"
:
">= 0.6"
}
},
"node_modules/node-fetch"
:
{
"version"
:
"2.7.0"
,
"resolved"
:
"https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz"
,
"integrity"
:
"sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A=="
,
"dependencies"
:
{
"whatwg-url"
:
"^5.0.0"
},
"engines"
:
{
"node"
:
"4.x || >=6.0.0"
},
"peerDependencies"
:
{
"encoding"
:
"^0.1.0"
},
"peerDependenciesMeta"
:
{
"encoding"
:
{
"optional"
:
true
}
}
},
"node_modules/object-assign"
:
{
"version"
:
"4.1.1"
,
"resolved"
:
"https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz"
,
...
...
@@ -896,6 +932,11 @@
"node"
:
">=0.6"
}
},
"node_modules/tr46"
:
{
"version"
:
"0.0.3"
,
"resolved"
:
"https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz"
,
"integrity"
:
"sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/ts-node"
:
{
"version"
:
"10.9.2"
,
"resolved"
:
"https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz"
,
...
...
@@ -1001,6 +1042,20 @@
"node"
:
">= 0.8"
}
},
"node_modules/webidl-conversions"
:
{
"version"
:
"3.0.1"
,
"resolved"
:
"https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz"
,
"integrity"
:
"sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"node_modules/whatwg-url"
:
{
"version"
:
"5.0.0"
,
"resolved"
:
"https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz"
,
"integrity"
:
"sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw=="
,
"dependencies"
:
{
"tr46"
:
"~0.0.3"
,
"webidl-conversions"
:
"^3.0.0"
}
},
"node_modules/yn"
:
{
"version"
:
"3.1.1"
,
"resolved"
:
"https://registry.npmjs.org/yn/-/yn-3.1.1.tgz"
,
...
...
backend/package.json
View file @
a1584923
...
...
@@ -11,7 +11,8 @@
"license"
:
"ISC"
,
"dependencies"
:
{
"cors"
:
"^2.8.5"
,
"express"
:
"^4.19.2"
"express"
:
"^4.19.2"
,
"i18next-http-backend"
:
"^2.5.0"
},
"devDependencies"
:
{
"@types/cors"
:
"^2.8.17"
,
...
...
front/package-lock.json
View file @
a1584923
...
...
@@ -8,8 +8,11 @@
"name"
:
"front"
,
"version"
:
"0.0.0"
,
"dependencies"
:
{
"i18next"
:
"^23.10.1"
,
"i18next-http-backend"
:
"^2.5.0"
,
"react"
:
"^18.2.0"
,
"react-dom"
:
"^18.2.0"
"react-dom"
:
"^18.2.0"
,
"react-i18next"
:
"^14.1.0"
},
"devDependencies"
:
{
"@types/react"
:
"^18.2.66"
,
...
...
@@ -343,6 +346,17 @@
"@babel/core"
:
"^7.0.0-0"
}
},
"node_modules/@babel/runtime"
:
{
"version"
:
"7.24.1"
,
"resolved"
:
"https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.1.tgz"
,
"integrity"
:
"sha512-+BIznRzyqBf+2wCTxcKE3wDjfGeCoVE61KSHGpkzqrLi8qxqFwBeUFyId2cxkTmm55fzDGnm0+yCxaxygrLUnQ=="
,
"dependencies"
:
{
"regenerator-runtime"
:
"^0.14.0"
},
"engines"
:
{
"node"
:
">=6.9.0"
}
},
"node_modules/@babel/template"
:
{
"version"
:
"7.24.0"
,
"resolved"
:
"https://registry.npmjs.org/@babel/template/-/template-7.24.0.tgz"
,
...
...
@@ -1687,6 +1701,14 @@
"integrity"
:
"sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="
,
"dev"
:
true
},
"node_modules/cross-fetch"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz"
,
"integrity"
:
"sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g=="
,
"dependencies"
:
{
"node-fetch"
:
"^2.6.12"
}
},
"node_modules/cross-spawn"
:
{
"version"
:
"7.0.3"
,
"resolved"
:
"https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz"
,
...
...
@@ -2340,6 +2362,44 @@
"node"
:
">=4"
}
},
"node_modules/html-parse-stringify"
:
{
"version"
:
"3.0.1"
,
"resolved"
:
"https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz"
,
"integrity"
:
"sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg=="
,
"dependencies"
:
{
"void-elements"
:
"3.1.0"
}
},
"node_modules/i18next"
:
{
"version"
:
"23.10.1"
,
"resolved"
:
"https://registry.npmjs.org/i18next/-/i18next-23.10.1.tgz"
,
"integrity"
:
"sha512-NDiIzFbcs3O9PXpfhkjyf7WdqFn5Vq6mhzhtkXzj51aOcNuPNcTwuYNuXCpHsanZGHlHKL35G7huoFeVic1hng=="
,
"funding"
:
[
{
"type"
:
"individual"
,
"url"
:
"https://locize.com"
},
{
"type"
:
"individual"
,
"url"
:
"https://locize.com/i18next.html"
},
{
"type"
:
"individual"
,
"url"
:
"https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
}
],
"dependencies"
:
{
"@babel/runtime"
:
"^7.23.2"
}
},
"node_modules/i18next-http-backend"
:
{
"version"
:
"2.5.0"
,
"resolved"
:
"https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-2.5.0.tgz"
,
"integrity"
:
"sha512-Z/aQsGZk1gSxt2/DztXk92DuDD20J+rNudT7ZCdTrNOiK8uQppfvdjq9+DFQfpAnFPn3VZS+KQIr1S/W1KxhpQ=="
,
"dependencies"
:
{
"cross-fetch"
:
"4.0.0"
}
},
"node_modules/ignore"
:
{
"version"
:
"5.3.1"
,
"resolved"
:
"https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz"
,
...
...
@@ -2624,6 +2684,25 @@
"integrity"
:
"sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw=="
,
"dev"
:
true
},
"node_modules/node-fetch"
:
{
"version"
:
"2.7.0"
,
"resolved"
:
"https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz"
,
"integrity"
:
"sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A=="
,
"dependencies"
:
{
"whatwg-url"
:
"^5.0.0"
},
"engines"
:
{
"node"
:
"4.x || >=6.0.0"
},
"peerDependencies"
:
{
"encoding"
:
"^0.1.0"
},
"peerDependenciesMeta"
:
{
"encoding"
:
{
"optional"
:
true
}
}
},
"node_modules/node-releases"
:
{
"version"
:
"2.0.14"
,
"resolved"
:
"https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz"
,
...
...
@@ -2841,6 +2920,27 @@
"react"
:
"^18.2.0"
}
},
"node_modules/react-i18next"
:
{
"version"
:
"14.1.0"
,
"resolved"
:
"https://registry.npmjs.org/react-i18next/-/react-i18next-14.1.0.tgz"
,
"integrity"
:
"sha512-3KwX6LHpbvGQ+sBEntjV4sYW3Zovjjl3fpoHbUwSgFHf0uRBcbeCBLR5al6ikncI5+W0EFb71QXZmfop+J6NrQ=="
,
"dependencies"
:
{
"@babel/runtime"
:
"^7.23.9"
,
"html-parse-stringify"
:
"^3.0.1"
},
"peerDependencies"
:
{
"i18next"
:
">= 23.2.3"
,
"react"
:
">= 16.8.0"
},
"peerDependenciesMeta"
:
{
"react-dom"
:
{
"optional"
:
true
},
"react-native"
:
{
"optional"
:
true
}
}
},
"node_modules/react-refresh"
:
{
"version"
:
"0.14.0"
,
"resolved"
:
"https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz"
,
...
...
@@ -2850,6 +2950,11 @@
"node"
:
">=0.10.0"
}
},
"node_modules/regenerator-runtime"
:
{
"version"
:
"0.14.1"
,
"resolved"
:
"https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz"
,
"integrity"
:
"sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="
},
"node_modules/resolve-from"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz"
,
...
...
@@ -3084,6 +3189,11 @@
"node"
:
">=8.0"
}
},
"node_modules/tr46"
:
{
"version"
:
"0.0.3"
,
"resolved"
:
"https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz"
,
"integrity"
:
"sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/ts-api-utils"
:
{
"version"
:
"1.3.0"
,
"resolved"
:
"https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz"
,
...
...
@@ -3227,6 +3337,28 @@
}
}
},
"node_modules/void-elements"
:
{
"version"
:
"3.1.0"
,
"resolved"
:
"https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz"
,
"integrity"
:
"sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w=="
,
"engines"
:
{
"node"
:
">=0.10.0"
}
},
"node_modules/webidl-conversions"
:
{
"version"
:
"3.0.1"
,
"resolved"
:
"https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz"
,
"integrity"
:
"sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"node_modules/whatwg-url"
:
{
"version"
:
"5.0.0"
,
"resolved"
:
"https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz"
,
"integrity"
:
"sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw=="
,
"dependencies"
:
{
"tr46"
:
"~0.0.3"
,
"webidl-conversions"
:
"^3.0.0"
}
},
"node_modules/which"
:
{
"version"
:
"2.0.2"
,
"resolved"
:
"https://registry.npmjs.org/which/-/which-2.0.2.tgz"
,
...
...
front/package.json
View file @
a1584923
...
...
@@ -10,8 +10,11 @@
"preview"
:
"vite preview"
},
"dependencies"
:
{
"i18next"
:
"^23.10.1"
,
"i18next-http-backend"
:
"^2.5.0"
,
"react"
:
"^18.2.0"
,
"react-dom"
:
"^18.2.0"
"react-dom"
:
"^18.2.0"
,
"react-i18next"
:
"^14.1.0"
},
"devDependencies"
:
{
"@types/react"
:
"^18.2.66"
,
...
...
front/src/App.tsx
View file @
a1584923
import
{
useState
}
from
'react'
import
reactLogo
from
'./assets/react.svg'
import
viteLogo
from
'/vite.svg'
import
{
useTranslation
}
from
"react-i18next"
;
import
'./App.css'
function
App
()
{
const
[
count
,
setCount
]
=
useState
(
0
)
const
{
t
,
i18n
}
=
useTranslation
();
const
changeLang
=
(
lang
:
string
)
=>
{
i18n
.
changeLanguage
(
lang
);
localStorage
.
setItem
(
'lang'
,
lang
);
}
return
(
<>
<
div
>
<
a
href=
"https://vitejs.dev"
target=
"_blank"
>
<
img
src=
{
viteLogo
}
className=
"logo"
alt=
"Vite logo"
/>
</
a
>
<
a
href=
"https://react.dev"
target=
"_blank"
>
<
img
src=
{
reactLogo
}
className=
"logo react"
alt=
"React logo"
/>
</
a
>
</
div
>
<
h1
>
Vite + React
</
h1
>
<
div
className=
"card"
>
<
button
onClick=
{
()
=>
setCount
((
count
)
=>
count
+
1
)
}
>
count is
{
count
}
</
button
>
<
p
>
Edit
<
code
>
src/App.tsx
</
code
>
and save to test HMR
</
p
>
<
button
onClick=
{
()
=>
changeLang
(
'en'
)
}
>
En
</
button
>
<
button
onClick=
{
()
=>
changeLang
(
'ru'
)
}
>
Ru
</
button
>
<
button
onClick=
{
()
=>
changeLang
(
'kz'
)
}
>
Kz
</
button
>
</
div
>
<
p
className=
"read-the-docs"
>
Click on the Vite and React logos to learn more
</
p
>
<
h2
>
{
t
(
'hi'
,
'test'
)
}
</
h2
>
</>
)
}
...
...
front/src/assets/locals/en/translation.json
0 → 100644
View file @
a1584923
{
"hi"
:
"hey"
}
\ No newline at end of file
front/src/assets/locals/kz/translation.json
0 → 100644
View file @
a1584923
{
"hi"
:
"salem"
}
\ No newline at end of file
front/src/assets/locals/ru/translation.json
0 → 100644
View file @
a1584923
{
"hi"
:
"privet"
}
\ No newline at end of file
front/src/i18n.ts
0 → 100644
View file @
a1584923
import
i18n
from
"i18next"
;
import
{
initReactI18next
}
from
"react-i18next"
;
import
HttpBackend
from
'i18next-http-backend'
;
i18n
.
use
(
initReactI18next
)
// passes i18n down to react-i18next
.
use
(
HttpBackend
)
.
init
({
backend
:
{
loadPath
:
'http://localhost:8000/locales/{{lng}}/{{ns}}.json'
,
},
debug
:
true
,
fallbackLng
:
localStorage
.
getItem
(
'lang'
)
||
"ru"
,
interpolation
:
{
escapeValue
:
false
// react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
}
});
front/src/main.tsx
View file @
a1584923
...
...
@@ -2,6 +2,7 @@ import React from 'react'
import
ReactDOM
from
'react-dom/client'
import
App
from
'./App.tsx'
import
'./index.css'
import
'./i18n.ts'
;
ReactDOM
.
createRoot
(
document
.
getElementById
(
'root'
)
!
).
render
(
<
React
.
StrictMode
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment