-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/lokalise/i18n-ally into fea…
…t/args-pre-suf
- Loading branch information
Showing
125 changed files
with
13,496 additions
and
148 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
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
7 changes: 7 additions & 0 deletions
7
examples/by-features/custom-scope-range/.vscode/i18n-ally-custom-framework.yml
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,7 @@ | ||
languageIds: | ||
- javascript | ||
- typescript | ||
- javascriptreact | ||
- typescriptreact | ||
scopeRangeRegex: "customScopeRangeFn\\(\\s*\\[?\\s*['\"`](.*?)['\"`]" | ||
monopoly: false |
7 changes: 7 additions & 0 deletions
7
examples/by-features/custom-scope-range/.vscode/settings.json
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,7 @@ | ||
{ | ||
"i18n-ally.localesPaths": "public/locales", | ||
"i18n-ally.enabledFrameworks": ["react", "i18next", "custom"], | ||
"i18n-ally.namespace": true, | ||
"i18n-ally.pathMatcher": "{locale}/{namespaces}.json", | ||
"i18n-ally.keystyle": "nested" | ||
} |
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,12 @@ | ||
{ | ||
"name": "custom-scope-range", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"i18next": "20.3.0", | ||
"i18next-xhr-backend": "3.2.2", | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2", | ||
"react-i18next": "11.9.0" | ||
} | ||
} |
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,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="theme-color" content="#000000"> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
examples/by-features/custom-scope-range/public/locales/en/pages/home.json
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,3 @@ | ||
{ | ||
"title": "Home" | ||
} |
11 changes: 11 additions & 0 deletions
11
examples/by-features/custom-scope-range/public/locales/en/translation.json
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,11 @@ | ||
{ | ||
"title": "hello", | ||
"description": { | ||
"part1": "To get started, edit <1>src/App.js</1> and save to reload.", | ||
"part2": "Switch language between english and german using buttons above." | ||
}, | ||
"titlew": "ok", | ||
"foo": { | ||
"bar": "foobar" | ||
} | ||
} |
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,10 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-header { | ||
background-color: #222; | ||
height: 100px; | ||
padding: 20px; | ||
color: white; | ||
} |
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,78 @@ | ||
/* eslint-disable no-undef */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable no-unused-vars */ | ||
// eslint-disable-next-line no-use-before-define | ||
import React from 'react' | ||
import { Trans } from 'react-i18next' | ||
import { customScopeRangeFn } from './customScopeRange' | ||
import './App.css' | ||
|
||
// Component using the Trans component | ||
function MyComponent() { | ||
return ( | ||
<Trans i18nKey="translation:description.part1"> | ||
To get started, edit <code>src/App.js</code> and save to reload. | ||
</Trans> | ||
) | ||
} | ||
|
||
// page uses the hook | ||
function Page() { | ||
const { t } = customScopeRangeFn() | ||
|
||
return ( | ||
<div className="App"> | ||
<div className="App-intro"> | ||
<MyComponent /> | ||
</div> | ||
<div>{t('translation:description.part2')}</div> | ||
{/* plain <Trans>, #423 */} | ||
<Trans i18nKey="translation:description.part2">Fallback text</Trans> | ||
</div> | ||
) | ||
} | ||
|
||
// function with scope | ||
function Page2() { | ||
const { t } = customScopeRangeFn(['translation:foo']) | ||
|
||
// inside default namespace ("foo.bar") | ||
t('bar') | ||
|
||
// explicit namespace | ||
t('pages.home:title') | ||
t('pages/home:title') | ||
} | ||
|
||
// function with another scope | ||
function Page3() { | ||
const { t } = customScopeRangeFn('pages/home') | ||
|
||
t('title') | ||
|
||
// explicit namespace | ||
t('translation:title') | ||
} | ||
|
||
// function with scope in options | ||
function Page4() { | ||
const { t } = customScopeRangeFn('pages/home') | ||
|
||
t('title') | ||
|
||
// explicit namespace | ||
t('title', { ns: 'translation' }) | ||
} | ||
|
||
// component with scope in props | ||
function Page5() { | ||
const { t } = customScopeRangeFn('pages/home') | ||
|
||
return ( | ||
<div className="App"> | ||
<Trans t={t} i18nKey="title"></Trans> | ||
{/* explicit namespace */} | ||
<Trans t={t} i18nKey="title" ns="translation"></Trans> | ||
</div> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
examples/by-features/custom-scope-range/src/customScopeRange.js
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 @@ | ||
export { useTranslation as customScopeRangeFn } from 'react-i18next' |
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,18 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import React from 'react' | ||
import i18n from 'i18next' | ||
import { initReactI18next } from 'react-i18next' | ||
|
||
i18n | ||
.use(Backend) | ||
.use(initReactI18next) | ||
.init({ | ||
fallbackLng: 'en', | ||
debug: true, | ||
|
||
interpolation: { | ||
escapeValue: false, // not needed for react as it escapes by default | ||
}, | ||
}) | ||
|
||
export default i18n |
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,8 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-use-before-define | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import App from './App' | ||
|
||
import './i18n' | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')) |
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,23 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
29 changes: 29 additions & 0 deletions
29
examples/by-frameworks/i18n-js/.vscode/i18n-ally-custom-framework.yml
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,29 @@ | ||
# .vscode/i18n-ally-custom-framework.yml | ||
|
||
# An array of strings which contain Language Ids defined by VS Code | ||
# You can check avaliable language ids here: https://code.visualstudio.com/docs/languages/overview#_language-id | ||
languageIds: | ||
- javascript | ||
- typescript | ||
- javascriptreact | ||
- typescriptreact | ||
|
||
# An array of RegExes to find the key usage. **The key should be captured in the first match group**. | ||
# You should unescape RegEx strings in order to fit in the YAML file | ||
# To help with this, you can use https://www.freeformatter.com/json-escape.html | ||
usageMatchRegex: | ||
# The following example shows how to detect `t("your.i18n.keys")` | ||
# the `{key}` will be placed by a proper keypath matching regex, | ||
# you can ignore it and use your own matching rules as well | ||
#- "[^\\w\\d]t\\(['\"`]({key})['\"`]" | ||
- "(?:i18n|I18n)\\.t\\(\\s*['\"`]({key})['\"`]" | ||
|
||
# An array of strings containing refactor templates. | ||
# The "$1" will be replaced by the keypath specified. | ||
# Optional: uncomment the following two lines to use | ||
|
||
# refactorTemplates: | ||
# - i18n.get("$1") | ||
|
||
# If set to true, only enables this custom framework (will disable all built-in frameworks) | ||
monopoly: true |
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,5 @@ | ||
{ | ||
"i18n-ally.localesPaths": [ | ||
"src/locales" | ||
] | ||
} |
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,70 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `yarn start` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.\ | ||
You will also see any lint errors in the console. | ||
|
||
### `yarn test` | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `yarn build` | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `yarn eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). | ||
|
||
### Code Splitting | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) | ||
|
||
### Analyzing the Bundle Size | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) | ||
|
||
### Making a Progressive Web App | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) | ||
|
||
### Advanced Configuration | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) | ||
|
||
### Deployment | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) | ||
|
||
### `yarn build` fails to minify | ||
|
||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) |
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,39 @@ | ||
{ | ||
"name": "i18n-js", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@testing-library/jest-dom": "^5.11.4", | ||
"@testing-library/react": "^11.1.0", | ||
"@testing-library/user-event": "^12.1.10", | ||
"i18n-js": "3.8.0", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-scripts": "4.0.3", | ||
"web-vitals": "^1.0.1" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test", | ||
"eject": "react-scripts eject" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.