generated from atls-lab/template
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: locales xtraction #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FrankJaskon
wants to merge
5
commits into
master
Choose a base branch
from
feat/extract-translations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ae3ae86
feat: add extraction of translations
FrankJaskon 41fec05
feat: add locales-generator package
FrankJaskon c10b69c
chore: format
FrankJaskon a3eb14d
chore: add constants
FrankJaskon 2cd566f
fix: rename dist to temporary
FrankJaskon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+122 KB
.yarn/cache/@formatjs-ecma402-abstract-npm-1.18.2-281c9afdd0-e761653887.zip
Binary file not shown.
Binary file added
BIN
+4.83 KB
.yarn/cache/@formatjs-fast-memoize-npm-2.2.0-4a46a61b8b-8697fe72a7.zip
Binary file not shown.
Binary file added
BIN
+54.1 KB
.yarn/cache/@formatjs-icu-messageformat-parser-npm-2.7.6-59cd895220-5baf9c1cf4.zip
Binary file not shown.
Binary file added
BIN
+13.7 KB
.yarn/cache/@formatjs-icu-skeleton-parser-npm-1.8.0-0f1fd4bf3f-8cd96d9075.zip
Binary file not shown.
Binary file added
BIN
+5.98 MB
.yarn/cache/@formatjs-intl-displaynames-npm-6.6.6-e035dc475b-b3c4ed7e7e.zip
Binary file not shown.
Binary file added
BIN
+403 KB
.yarn/cache/@formatjs-intl-listformat-npm-7.5.5-496f84d41c-78907a1021.zip
Binary file not shown.
Binary file added
BIN
+41.2 KB
.yarn/cache/@formatjs-intl-localematcher-npm-0.5.4-e30cfcd8fd-780cb29b42.zip
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+31.5 MB
...darwin-arm64-npm-14.1.0-6d433a23a7-10.zip → ...inux-x64-gnu-npm-14.1.0-5a9ae6f5df-10.zip
Binary file not shown.
Binary file added
BIN
+3.48 KB
.yarn/cache/@types-hoist-non-react-statics-npm-3.3.5-98b8d8e47b-b645b062a2.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or 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 hidden or 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,3 @@ | ||
{ | ||
"text": "text" | ||
} |
42 changes: 42 additions & 0 deletions
42
pages-router/entrypoints/renderer/extract-all-translations.js
This file contains hidden or 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,42 @@ | ||
/* eslint-disable */ | ||
|
||
import { readdirSync, existsSync, readFileSync, writeFileSync } from 'fs' | ||
import { join } from 'path' | ||
import { execSync } from 'child_process' | ||
|
||
const processDirectory = (startPath, folderName, allLocales) => { | ||
Nelfimov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!existsSync(startPath)) { | ||
console.log('No directory ', startPath) | ||
return | ||
} | ||
|
||
const directories = readdirSync(startPath, { withFileTypes: true }) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name) | ||
|
||
directories.forEach((dir) => { | ||
const localePath = join(startPath, dir) | ||
if (existsSync(`${localePath}/${folderName}`)) { | ||
Nelfimov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const command = `formatjs extract "${localePath}/**/*.tsx" --out-file "${localePath}/${folderName}/ru.json" --format simple` | ||
console.log(`Running: ${command}`) | ||
execSync(command, { stdio: 'inherit' }) | ||
allLocales.push(`${localePath}/${folderName}/ru.json`) | ||
} | ||
}) | ||
} | ||
|
||
const mergeLocales = (files, outputPath) => { | ||
const mergedLocales = {} | ||
files.forEach((file) => { | ||
if (existsSync(file)) { | ||
const content = JSON.parse(readFileSync(file, 'utf8')) | ||
Object.assign(mergedLocales, content) | ||
} | ||
}) | ||
writeFileSync(outputPath, JSON.stringify(mergedLocales, null, 2), 'utf8') | ||
} | ||
|
||
const allLocales = [] | ||
processDirectory('../../fragments', 'locales', allLocales) | ||
processDirectory('../../pages', 'locales', allLocales) | ||
mergeLocales(allLocales, './locales/ru.json') |
This file contains hidden or 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,7 @@ | ||
{ | ||
"app.navbar.hello": "HELLO TOO FROM NAVBAR", | ||
"app.navbar_fragment.identity": "IDENTITY", | ||
"app.sidebar-fragment.identity": "SIDEBAR", | ||
"app.home_page.content": "CONTENT", | ||
"app.home_page.hello": "HELLO FROM HOME" | ||
} |
This file contains hidden or 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 hidden or 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,11 +1,16 @@ | ||
import React from 'react' | ||
import { IntlProvider } from 'react-intl' | ||
|
||
import { ThemeProvider } from '@ui/theme' | ||
|
||
import messages from '../../locales/ru.json' | ||
|
||
const App = ({ Component, pageProps, ...props }) => ( | ||
<ThemeProvider> | ||
<Component {...pageProps} {...props} /> | ||
</ThemeProvider> | ||
<IntlProvider defaultLocale='ru' locale='ru' messages={messages}> | ||
<ThemeProvider> | ||
<Component {...pageProps} {...props} /> | ||
</ThemeProvider> | ||
</IntlProvider> | ||
) | ||
|
||
export default App |
This file contains hidden or 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 @@ | ||
{ | ||
"app.navbar.hello": "HELLO TOO FROM NAVBAR", | ||
"app.navbar_fragment.identity": "IDENTITY" | ||
} |
This file contains hidden or 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 @@ | ||
{ | ||
"name": "@app/navbar-fragment", | ||
"version": "0.0.1", | ||
"main": "src/index.ts", | ||
"dependencies": { | ||
"@ui/hello": "workspace:0.0.1", | ||
"@ui/layout": "workspace:0.0.1", | ||
"@ui/text": "workspace:0.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "18.2.48", | ||
"@types/react-dom": "18.2.18", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"react-intl": "6.6.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "*", | ||
"react-dom": "*", | ||
"react-intl": "*" | ||
} | ||
} |
This file contains hidden or 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 @@ | ||
export * from './navbar.component' |
This file contains hidden or 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,33 @@ | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
import { useIntl } from 'react-intl' | ||
|
||
import { Hello } from '@ui/hello' | ||
import { Box } from '@ui/layout' | ||
import { Column } from '@ui/layout' | ||
import { Text } from '@ui/text' | ||
|
||
export const Navbar = () => { | ||
const { formatMessage } = useIntl() | ||
return ( | ||
<Column gap={20}> | ||
<Box | ||
justifyContent='center' | ||
alignItems='center' | ||
padding='huge' | ||
backgroundColor='darkRed' | ||
border='boldLightGray' | ||
boxShadow='black.fifteenHundredthsTransparent' | ||
height={50} | ||
gap={20} | ||
> | ||
<Text color='white'> | ||
<FormattedMessage id='app.navbar_fragment.identity' defaultMessage='IDENTITY' /> | ||
</Text> | ||
<Hello | ||
hello={formatMessage({ id: 'app.navbar.hello', defaultMessage: 'HELLO TOO FROM NAVBAR' })} | ||
/> | ||
</Box> | ||
</Column> | ||
) | ||
} |
This file contains hidden or 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,3 @@ | ||
{ | ||
"app.sidebar-fragment.identity": "SIDEBAR" | ||
} |
This file contains hidden or 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,21 @@ | ||
{ | ||
"name": "@app/sidebar-fragment", | ||
"version": "0.0.1", | ||
"main": "src/index.ts", | ||
"dependencies": { | ||
"@ui/layout": "workspace:0.0.1", | ||
"@ui/text": "workspace:0.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "18.2.48", | ||
"@types/react-dom": "18.2.18", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"react-intl": "6.6.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "*", | ||
"react-dom": "*", | ||
"react-intl": "*" | ||
} | ||
} |
This file contains hidden or 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 @@ | ||
export * from './sidebar.component' |
This file contains hidden or 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 @@ | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
|
||
import { Box } from '@ui/layout' | ||
import { Text } from '@ui/text' | ||
|
||
export const Sidebar = () => ( | ||
<Box | ||
justifyContent='center' | ||
alignItems='center' | ||
height='calc(100vh - 50px)' | ||
width={200} | ||
padding='huge' | ||
backgroundColor='darkRed' | ||
borderTop='boldLightGray' | ||
borderRight='boldLightGray' | ||
> | ||
<Text> | ||
<FormattedMessage id='app.sidebar-fragment.identity' defaultMessage='SIDEBAR' /> | ||
</Text> | ||
</Box> | ||
) |
This file contains hidden or 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 @@ | ||
{ | ||
"app.home_page.content": "CONTENT", | ||
"app.home_page.hello": "HELLO FROM HOME" | ||
} |
This file contains hidden or 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 hidden or 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,12 +1,32 @@ | ||
import React from 'react' | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
import { useIntl } from 'react-intl' | ||
|
||
import { Hello } from '@ui/hello' | ||
import { Navbar } from '@app/navbar-fragment' | ||
import { Sidebar } from '@app/sidebar-fragment' | ||
import { Hello } from '@ui/hello' | ||
import { Box } from '@ui/layout' | ||
import { Row } from '@ui/layout' | ||
import { Text } from '@ui/text' | ||
|
||
const HomePage = () => ( | ||
<> | ||
<h1>HELLO</h1> | ||
<Hello /> | ||
</> | ||
) | ||
const HomePage = () => { | ||
const { formatMessage } = useIntl() | ||
return ( | ||
<> | ||
<Navbar /> | ||
<Row fill> | ||
<Sidebar /> | ||
<Box gap={20}> | ||
<Hello | ||
hello={formatMessage({ id: 'app.home_page.hello', defaultMessage: 'HELLO FROM HOME' })} | ||
/> | ||
<Text> | ||
<FormattedMessage id='app.home_page.content' defaultMessage='CONTENT' /> | ||
</Text> | ||
</Box> | ||
</Row> | ||
</> | ||
) | ||
} | ||
|
||
export default HomePage |
This file contains hidden or 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 @@ | ||
import React from 'react' | ||
|
||
export const Hello = () => <i>HELLO</i> | ||
export const Hello = ({ hello }: { hello?: string }) => ( | ||
<i>{hello ?? 'GLOOMY HELLO WITHOUT TRANSLATION'}</i> | ||
) |
This file contains hidden or 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,26 @@ | ||
{ | ||
"name": "@ui/text", | ||
"version": "0.0.1", | ||
"main": "src/index.ts", | ||
"dependencies": { | ||
"@atls-ui-parts/text": "0.1.1" | ||
}, | ||
"devDependencies": { | ||
"@emotion/react": "11.11.3", | ||
"@emotion/styled": "11.9.3", | ||
"@types/react": "18.2.48", | ||
"@types/react-dom": "18.2.18", | ||
"@types/styled-system": "5.1.22", | ||
"csstype": "3.1.2", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"styled-system": "5.1.5" | ||
}, | ||
"peerDependencies": { | ||
"@emotion/react": "*", | ||
"@emotion/styled": "*", | ||
"react": "*", | ||
"react-dom": "*", | ||
"styled-system": "*" | ||
} | ||
} |
This file contains hidden or 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,3 @@ | ||
'use client' | ||
|
||
export * from '@atls-ui-parts/text' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот с этим надо разобраться - почему он требует эмоушн хотя в зависимостях все есть. Проверь еще в гиперионе пожалуйста
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нам не нужно его явно в пирах получать?
@emotion/react
вообще не фигурирует в зависимостях для текста в гипперионеThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тогда надо обязательно добавить.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
создай пожалуйста таску на это дело