Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/lokalise/i18n-ally into fea…
Browse files Browse the repository at this point in the history
…t/args-pre-suf
  • Loading branch information
chuyan.zhang committed Aug 28, 2023
2 parents f651e1d + 53dc59c commit 4b1e327
Show file tree
Hide file tree
Showing 100 changed files with 1,586 additions and 148 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"i18n-ally.keystyle": "flat",
"i18n-ally.preferredDelimiter": "_",
"i18n-ally.sortKeys": true,
"i18n-ally.sortCompare": "binary",
"i18n-ally.keepFulfilled": true,
"i18n-ally.translate.promptSource": true,
"i18n-ally.pathMatcher": "{locale}.json",
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.10.0](https://github.com/lokalise/i18n-ally/compare/v2.9.1...v2.10.0) (2023-07-11)

### ⚡ Features

* Add i18next-shopify framework ([#949](https://github.com/lokalise/i18n-ally/pull/949), [#970](https://github.com/lokalise/i18n-ally/pull/970))
* Add extraction support to react-i18next framework ([#951](https://github.com/lokalise/i18n-ally/pull/951))
* Display first available pluralization string if parent key of nested pluralization keys ([#950](https://github.com/lokalise/i18n-ally/pull/950))
* Support "Go to Definition" for nested pluralization keys ([#954](https://github.com/lokalise/i18n-ally/pull/954))

### 🐞 Bug Fixes

* implement scopes/namespaces for Transloco ([#684](https://github.com/lokalise/i18n-ally/issues/684)) ([43df97d](https://github.com/lokalise/i18n-ally/commit/43df97db80073230e528b7bf63610c903d886df8))
* Fixes usage report for non-missing derived keys ([#957](https://github.com/lokalise/i18n-ally/pull/957))
* Fixes Current File Panel report of not found keys ([Shopify/i18n-ally#7](https://github.com/Shopify/i18n-ally/pull/7))


### [2.9.1](https://github.com/lokalise/i18n-ally/compare/v2.9.0...v2.9.1) (2023-05-15)

### 🐞 Bug Fixes
Expand Down
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 examples/by-features/custom-scope-range/.vscode/settings.json
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"
}
12 changes: 12 additions & 0 deletions examples/by-features/custom-scope-range/package.json
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"
}
}
15 changes: 15 additions & 0 deletions examples/by-features/custom-scope-range/public/index.html
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"title": "Home"
}
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"
}
}
10 changes: 10 additions & 0 deletions examples/by-features/custom-scope-range/src/App.css
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;
}
78 changes: 78 additions & 0 deletions examples/by-features/custom-scope-range/src/App.jsx
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>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { useTranslation as customScopeRangeFn } from 'react-i18next'
18 changes: 18 additions & 0 deletions examples/by-features/custom-scope-range/src/i18n.js
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
8 changes: 8 additions & 0 deletions examples/by-features/custom-scope-range/src/index.js
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'))
8 changes: 8 additions & 0 deletions examples/by-frameworks/i18next-shopify/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"i18n-ally.localesPaths": "public/locales",
"i18n-ally.enabledFrameworks": ["i18next-shopify"],
"i18n-ally.namespace": true,
"i18n-ally.pathMatcher": "{locale}/{namespaces}.json",
"i18n-ally.keystyle": "nested",
"i18n-ally.keysInUse": ["description.part2_whatever"]
}
21 changes: 21 additions & 0 deletions examples/by-frameworks/i18next-shopify/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "react_usinghooks",
"version": "0.1.0",
"private": true,
"dependencies": {
"i18next": "20.3.0",
"i18next-browser-languagedetector": "6.1.1",
"i18next-xhr-backend": "3.2.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-i18next": "11.9.0",
"@shopify/i18next-shopify": "0.2.3",
"react-scripts": "4.0.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
15 changes: 15 additions & 0 deletions examples/by-frameworks/i18next-shopify/public/index.html
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"title": "Zuhause"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"title": "Willkommen zu react und react-i18next",
"description": {
"part1": "Um loszulegen, ändere <1>src/App(DE).js</1> speicheren und neuladen.",
"part2": "Ändere die Sprachen zwischen deutsch und englisch mit Hilfe der beiden Schalter."
},
"count": {
"one": "{{count}} Satz übersetzt!",
"other": "{{count}} Sätze übersetzt!"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"title": "Home"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"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"
},
"count": {
"one": "{{count}} phrase translated!",
"other": "{{count}} phrases translated!"
}
}
10 changes: 10 additions & 0 deletions examples/by-frameworks/i18next-shopify/src/App.css
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;
}
Loading

0 comments on commit 4b1e327

Please sign in to comment.