-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from osakunta/translations-sync
Translations sync
- Loading branch information
Showing
6 changed files
with
78 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CMS_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import dotenv from "dotenv"; | ||
dotenv.config({ path: ".env.local" }); | ||
import { writeFile } from "fs/promises"; | ||
|
||
export async function fetchTranslations() { | ||
if (process.env.CMS_URL === undefined) { | ||
console.error("CMS_URL is not defined. Could not fetch translations."); | ||
return; | ||
} | ||
|
||
try { | ||
console.log("Fetching translations.json"); | ||
const response = await fetch(process.env.CMS_URL + "/items/text"); | ||
if (!response.ok) { | ||
throw new Error( | ||
`Failed to download translations: ${response.statusText}`, | ||
); | ||
} | ||
|
||
const data = await response.json(); | ||
|
||
await writeFile( | ||
"./hooks/translations.json", | ||
JSON.stringify(data, null, 2) + "\n", | ||
); // prettier wants a trailing newline | ||
console.log( | ||
`Downloaded and saved translations.json ${response.status === 304 ? "cached" : ""}`, | ||
); | ||
} catch (error) { | ||
console.error("Error downloading translations.json :", error); | ||
} | ||
} | ||
|
||
fetchTranslations(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"key": "new_test", | ||
"text_fi": "moi", | ||
"text_en": "hi", | ||
"text_sv": "hej" | ||
}, | ||
{ | ||
"key": "general:nation", | ||
"text_fi": "Satakuntalainen Osakunta", | ||
"text_en": "Satakunta Nation", | ||
"text_sv": "Satakunta Nation" | ||
}, | ||
{ | ||
"key": "home:welcome", | ||
"text_fi": "Tervetuloa Satakuntalaisen Osakunnan sivuille", | ||
"text_en": "Welcome to the website of Satakuntalainen Osakunta", | ||
"text_sv": "Samma på svenska" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
output: "export", | ||
images: { | ||
unoptimized: true, | ||
}, | ||
reactStrictMode: true, | ||
const config = async () => { | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
output: "export", | ||
images: { | ||
unoptimized: true, | ||
}, | ||
reactStrictMode: true, | ||
}; | ||
|
||
return nextConfig; | ||
}; | ||
|
||
export default nextConfig; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters