-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Download translations on build, use API in dev mode
- Loading branch information
1 parent
1f4ba5d
commit b45046d
Showing
12 changed files
with
66 additions
and
35 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,2 @@ | ||
VITE_TOLGEE_API_URL=https://translate.ficsit.app | ||
VITE_TOLGEE_API_KEY=tgpak_grpxa5lfgvzdsnluovswknluonrtc3rxnzzw2nttmjww6 |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,3 +1,5 @@ | ||
graphql.schema.urql.json | ||
graphql.ts | ||
i18n/ | ||
* | ||
!*/ | ||
|
||
!/index.ts | ||
!graphql/index.ts |
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,4 @@ | ||
export * from './graphql'; | ||
import schema from './graphql.schema.urql.json'; | ||
|
||
export { schema }; |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
const child_process = require('child_process'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
require('dotenv').config(); | ||
|
||
const generatedDir = path.join(__dirname, '../src/lib/generated'); | ||
const i18nDir = path.join(generatedDir, 'i18n'); | ||
const i18nFile = path.join(i18nDir, 'index.ts'); | ||
|
||
if (fs.existsSync(i18nDir)) { | ||
console.log('Clearing i18n directory'); | ||
fs.rmSync(i18nDir, { recursive: true }); | ||
fs.mkdirSync(i18nDir); | ||
} | ||
|
||
console.log('Pulling translations'); | ||
child_process.execSync(`pnpm translations:pull -ak ${process.env.VITE_TOLGEE_API_KEY}`, { stdio: 'inherit' }); | ||
|
||
const langs = fs.readdirSync(i18nDir).map(file => file.replace('.json', '')); | ||
console.log('Languages:', langs.join(', ')); | ||
|
||
const fileContent = '/* eslint-disable */\n' | ||
+ langs.map(lang => `import ${lang.replace('-', '_')} from './${lang}.json';`).join('\n') | ||
+ '\n\n' | ||
+ 'export const i18n = {\n' | ||
+ langs.map(lang => ` "${lang}": ${lang.replace('-', '_')},`).join('\n') | ||
+ '\n};\n'; | ||
|
||
fs.writeFileSync(i18nFile, fileContent); | ||
console.log('Translations generated'); |
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