-
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.
- Loading branch information
1 parent
15dfe8d
commit 0db8a9e
Showing
19 changed files
with
10,605 additions
and
1 deletion.
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,9 @@ | ||
{ | ||
"extends": ["vazco/typescript"], | ||
"parser": "@typescript-eslint/parser", | ||
"ignorePatterns": ["dist/*"], | ||
"rules": { | ||
"react-hooks/exhaustive-deps": 1, | ||
"eslint-comments/require-description": 0 | ||
} | ||
} |
Validating CODEOWNERS rules …
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 @@ | ||
* @piotrpospiech |
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 @@ | ||
node_modules/ | ||
dist/ |
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 @@ | ||
node_modules/ |
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 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"bracketSpacing": true, | ||
"printWidth": 80, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "all" | ||
} |
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 @@ | ||
{ | ||
"extends": ["stylelint-config-standard"], | ||
"rules": { | ||
"selector-class-pattern": "^i18n-table--([a-z][a-z0-9]*)(-[a-z0-9]+)*$", | ||
"custom-property-pattern": "^i18n-table--([a-z][a-z0-9]*)(-[a-z0-9]+)*$" | ||
} | ||
} |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Vazco | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,2 +1,89 @@ | ||
# i18n-table | ||
A React component that helps organize and manage translations | ||
|
||
## Installation | ||
|
||
``` | ||
npm install i18n-table | ||
``` | ||
|
||
## Get started | ||
|
||
1. Import `TranslationManager` and styles | ||
|
||
```js | ||
import TranslationManager from 'i18n-table'; | ||
import 'i18n-table/dist/index.css'; | ||
``` | ||
|
||
2. Prepare translations | ||
|
||
```js | ||
const translations = { | ||
en: { | ||
colors: { | ||
red: 'Red', | ||
blue: 'Blue', | ||
green: 'Green', | ||
}, | ||
}, | ||
es: { | ||
colors: { | ||
red: 'Rojo', | ||
green: 'Verde', | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
`translations` object should have **locales** as keys and **objects or nested objects** as values. | ||
|
||
3. Prepare locales with full and local names. | ||
|
||
> [!IMPORTANT] | ||
> The `locale` property have to match with locale used in the first step. | ||
```js | ||
const locales = [ | ||
{ locale: 'en', fullName: 'English', localName: 'English' }, | ||
{ locale: 'es', fullName: 'Spanish', localName: 'Español' }, | ||
]; | ||
``` | ||
|
||
4. Render `TranslationManager` on your page | ||
|
||
```js | ||
export const App = () => ( | ||
<TranslationManager | ||
translations={translations} | ||
locales={locales} | ||
onSave={translations => { | ||
/* Handle saving translations - structure is the same as in the step 2. */ | ||
}} | ||
/> | ||
); | ||
``` | ||
|
||
5. If you want to write **your own styles**, copy `/src/lib/styles.css` file to your project, modify it and import it instead of `i18n-table/dist/index.css` | ||
|
||
6. You can also customize header translations. | ||
|
||
```js | ||
const componentTranslations = { | ||
save: t('save'), | ||
search: t('search'), | ||
select: t('select'), | ||
translationKey: t('translationKey'), | ||
}; | ||
|
||
export const App = () => ( | ||
<TranslationManager | ||
// ... | ||
componentTranslations={componentTranslations} | ||
onLocaleChange={locale => i18n.setLocale(locale)} | ||
/> | ||
); | ||
``` | ||
|
||
## License | ||
|
||
**Like every package maintained by [Vazco](https://vazco.eu/), i18n-table package is [MIT licensed](https://github.com/vazco/i18n-table/blob/master/LICENSE).** |
Oops, something went wrong.