Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nos Hs2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Språksamlingane
stadnamn
Nos Hs2023
Commits
316a9f9c
Commit
316a9f9c
authored
3 years ago
by
esikkala
Browse files
Options
Downloads
Patches
Plain Diff
Run translations generator in a separate script
parent
bbdbec28
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
package.json
+0
-2
0 additions, 2 deletions
package.json
src/server/translations_generator/index.js
+33
-25
33 additions, 25 deletions
src/server/translations_generator/index.js
with
33 additions
and
27 deletions
package.json
+
0
−
2
View file @
316a9f9c
...
...
@@ -11,13 +11,11 @@
"Heikki Rantala"
],
"scripts"
:
{
"prebuild"
:
"cross-env BABEL_ENV=node babel-node src/server/translations_generator/index.js"
,
"build"
:
"npm run build-client && npm run build-server"
,
"build-client"
:
"cross-env BABEL_ENV=browser webpack --progress --config webpack.client.prod.js"
,
"build-server"
:
"cross-env BABEL_ENV=node babel src/server --out-dir ./dist/server --copy-files"
,
"build-storybook"
:
"build-storybook -c .storybook -o docs"
,
"client"
:
"cross-env BABEL_ENV=browser webpack serve --config webpack.client.dev.js"
,
"predev"
:
"cross-env BABEL_ENV=node babel-node src/server/translations_generator/index.js"
,
"dev"
:
"concurrently --prefix none --kill-others
\"
npm run server
\"
\"
npm run client
\"
"
,
"server"
:
"cross-env BABEL_ENV=node NODE_ENV=development nodemon -r dotenv/config src/server/index.js --exec babel-node"
,
"sitemap"
:
"cross-env BABEL_ENV=node babel-node src/server/sitemap_generator/SitemapGenerator.js"
,
...
...
This diff is collapsed.
Click to expand it.
src/server/translations_generator/index.js
+
33
−
25
View file @
316a9f9c
...
...
@@ -19,22 +19,6 @@ const auth = new google.auth.GoogleAuth({
const
sheets
=
google
.
sheets
({
version
:
'
v4
'
,
auth
})
// const writeToGoogleSheet = async values => {
// try {
// const result = await sheets.spreadsheets.values.update({
// spreadsheetId,
// range: 'A:B',
// valueInputOption: 'RAW',
// requestBody: {
// values
// }
// })
// console.log(result)
// } catch (error) {
// console.error(error.errors)
// }
// }
const
readFromGoogleSheet
=
async
({
spreadsheetId
,
ranges
})
=>
{
try
{
const
result
=
await
sheets
.
spreadsheets
.
values
.
batchGet
({
...
...
@@ -67,6 +51,22 @@ const sheetValueRangesToFlatObject = valueRanges => {
},
{})
}
// const writeToGoogleSheet = async values => {
// try {
// const result = await sheets.spreadsheets.values.update({
// spreadsheetId,
// range: 'A:B',
// valueInputOption: 'RAW',
// requestBody: {
// values
// }
// })
// console.log(result)
// } catch (error) {
// console.error(error.errors)
// }
// }
// const flattened = flatten(localeEN)
// Object.keys(flattened).forEach(key => {
...
...
@@ -86,13 +86,21 @@ const sheetValueRangesToFlatObject = valueRanges => {
if
(
readTranslationsFromGoogleSheets
)
{
const
spreadsheetId
=
process
.
env
.
SHEETS_API_SHEET_ID
readFromGoogleSheet
({
spreadsheetId
,
ranges
:
[
'
Taulukko1!A:A
'
,
'
Taulukko1!B:B
'
]
}).
then
(
data
=>
{
const
flatObject
=
sheetValueRangesToFlatObject
(
data
)
writeToFile
(
'
src/client/translations/sampo/localeEN.json
'
,
unflatten
(
flatObject
))
})
readFromGoogleSheet
({
spreadsheetId
,
ranges
:
[
'
Taulukko1!A:A
'
,
'
Taulukko1!C:C
'
]
}).
then
(
data
=>
{
const
flatObject
=
sheetValueRangesToFlatObject
(
data
)
writeToFile
(
'
src/client/translations/sampo/localeFI.json
'
,
unflatten
(
flatObject
))
})
readFromGoogleSheet
({
spreadsheetId
,
ranges
:
[
'
Taulukko1!A:A
'
,
'
Taulukko1!B:B
'
]
})
.
then
(
data
=>
{
if
(
data
)
{
const
flatObject
=
sheetValueRangesToFlatObject
(
data
)
writeToFile
(
'
src/client/translations/sampo/localeEN.json
'
,
unflatten
(
flatObject
))
}
})
.
catch
(
error
=>
console
.
error
(
error
))
readFromGoogleSheet
({
spreadsheetId
,
ranges
:
[
'
Taulukko1!A:A
'
,
'
Taulukko1!C:C
'
]
})
.
then
(
data
=>
{
if
(
data
)
{
const
flatObject
=
sheetValueRangesToFlatObject
(
data
)
writeToFile
(
'
src/client/translations/sampo/localeFI.json
'
,
unflatten
(
flatObject
))
}
})
.
catch
(
error
=>
console
.
error
(
error
))
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment