-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from andreasremdt/v2
[WIP] 2.0.0
- Loading branch information
Showing
18 changed files
with
2,084 additions
and
1,298 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,13 @@ | ||
{ | ||
"env": { | ||
"test": { | ||
"plugins": [ | ||
"@babel/plugin-transform-modules-commonjs", | ||
"@babel/plugin-proposal-optional-chaining" | ||
] | ||
}, | ||
"development": { | ||
"presets": ["@babel/preset-env"] | ||
} | ||
} | ||
} |
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,15 +1,13 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true | ||
}, | ||
extends: "eslint:recommended", | ||
globals: { | ||
Atomics: "readonly", | ||
SharedArrayBuffer: "readonly" | ||
es2020: true, | ||
node: true, | ||
jest: true, | ||
}, | ||
extends: ['google', 'eslint:recommended', 'prettier'], | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: "module" | ||
} | ||
ecmaVersion: 11, | ||
sourceType: 'module', | ||
}, | ||
}; |
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 +1,6 @@ | ||
node_modules/ | ||
node_modules/ | ||
dist/ | ||
coverage/ | ||
|
||
package-lock.json | ||
yarn.lock |
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 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"singleQuote": 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 |
---|---|---|
|
@@ -3,6 +3,56 @@ | |
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [2.0.0] - 2020-07-29 | ||
|
||
### Breaking changes | ||
|
||
- This release is a complete rewrite of the codebase. | ||
- The methods `load()` and `getTranslationByKey()` have been removed in favor of a new API. Use `fetch()`, `translateForKey()`, and `translatePageTo()` instead. | ||
- The config option `languages` has been removed. | ||
- For more documentation on the new API, see the [Usage section](https://github.com/andreasremdt/simple-translator#usage) or the [API Reference](https://github.com/andreasremdt/simple-translator#api-reference). | ||
|
||
### Added | ||
|
||
- Added a config option `registerGlobally` that, if specified, registers a global helper with the same name as the given value. This allows you to translate single strings using shortcuts like `__('header.title')`. | ||
- Added a config option `persistKey` that specifies the name of the localStorage key. | ||
- Added a config option `debug` that, if set to `true`, prints useful error messages. | ||
- Added `fetch()` for easier JSON fetching. | ||
- Added `add()` to register new languages to the translator. | ||
- Added `remove()` to remove languages from the translator. | ||
- Added `translateForKey()` and `translatePageTo()` to translate single keys or the entire website. | ||
- Added `get currentLanguage` to get the currently used language. | ||
- Transpiled and minified UMD, ESM and CJS builds are available via [unpkg](https://unpkg.com/@andreasremdt/[email protected]/dist/umd/translator.min.js) and [npm](https://www.npmjs.com/package/@andreasremdt/simple-translator). | ||
- Added a build system for easier packaging and testing. | ||
- Added [CONTRIBUTING.md](https://github.com/andreasremdt/simple-translator/CONTRIBUTING.md) | ||
- Added [CODE_OF_CONDUCT.md](https://github.com/andreasremdt/simple-translator/CODE_OF_CONDUCT.md) | ||
|
||
### Changed | ||
|
||
- The [documentation](https://github.com/andreasremdt/simple-translator/#readme) has been updated and improved. | ||
|
||
### Removed | ||
|
||
- The option `languages` has been removed. | ||
- The method `load()` has been removed. | ||
- The method `getTranslationByKey()` has been removed. | ||
|
||
### Dependencies | ||
|
||
- Install `@babel/[email protected]`, | ||
- Install `@babel/[email protected]`, | ||
- Install `@babel/[email protected]`, | ||
- Install `@babel/[email protected]`, | ||
- Install `@rollup/[email protected]`, | ||
- Install `[email protected]`, | ||
- Install `[email protected]`, | ||
- Install `[email protected]`, | ||
- Install `[email protected]`, | ||
- Install `[email protected]`, | ||
- Install `[email protected]`, | ||
- Install `[email protected]`, | ||
- Install `[email protected]` | ||
|
||
## [1.2.0] - 2020-07-21 | ||
|
||
### Added | ||
|
@@ -13,8 +63,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
|
||
### Changed | ||
|
||
- `getTranslationByKey` uses the fallback language when provided | ||
- Update the documentation | ||
- `getTranslationByKey` uses the fallback language when provided. | ||
- Update the documentation. | ||
|
||
## [1.1.0] - 2020-04-04 | ||
|
||
|
@@ -26,8 +76,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
|
||
### Changed | ||
|
||
- Use cache to faster translate and save network data. | ||
- Print a warn message when a key was not found in the translation files. Thanks [@andi34](https://github.com/andi34). | ||
- Use cache to translate faster and save network data. | ||
- Print a warning message when a key was not found in the translation files. Thanks [@andi34](https://github.com/andi34). | ||
|
||
### Dependencies | ||
|
||
|
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,84 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our pledge | ||
|
||
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. | ||
|
||
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. | ||
|
||
## Our standards | ||
|
||
Examples of behavior that contributes to a positive environment for our community include: | ||
|
||
- Demonstrating empathy and kindness toward other people | ||
- Being respectful of differing opinions, viewpoints, and experiences | ||
- Giving and gracefully accepting constructive feedback | ||
- Accepting responsibility and apologizing to those affected by our mistakes, | ||
and learning from the experience | ||
- Focusing on what is best not just for us as individuals, but for the | ||
overall community | ||
|
||
Examples of unacceptable behavior include: | ||
|
||
- The use of sexualized language or imagery, and sexual attention or | ||
advances of any kind | ||
- Trolling, insulting or derogatory comments, and personal or political attacks | ||
- Public or private harassment | ||
- Publishing others' private information, such as a physical or email | ||
address, without their explicit permission | ||
- Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Enforcement responsibilities | ||
|
||
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior. They will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. | ||
|
||
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that don't align with this Code of Conduct. They will communicate reasons for moderation decisions when appropriate. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies within all community spaces and applies when an individual officially represents the community in public areas. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise, unacceptable behavior may be reported to the community leaders responsible for enforcement at [[email protected]](mailto:[email protected]). All complaints will be reviewed and investigated promptly and fairly. | ||
|
||
All community leaders are obligated to respect the privacy and security of the reporter of any incident. | ||
|
||
## Enforcement guidelines | ||
|
||
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: | ||
|
||
### 1. Correction | ||
|
||
**Community impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. | ||
|
||
**Consequence**: A private, written warning from community leaders provides clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. | ||
|
||
### 2. Warning | ||
|
||
**Community impact**: A violation through a single incident or series of actions. | ||
|
||
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited communication with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. | ||
|
||
### 3. Temporary ban | ||
|
||
**Community impact**: A severe violation of community standards, including sustained inappropriate behavior. | ||
|
||
**Consequence**: A temporary ban from any interaction or public communication with the community for a specified period. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. | ||
|
||
### 4. Permanent ban | ||
|
||
**Community impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of individuals, or aggression toward or disparagement of classes of individuals. | ||
|
||
**Consequence**: A permanent ban from any sort of public interaction within the community. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. | ||
|
||
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). | ||
|
||
[homepage]: https://www.contributor-covenant.org | ||
|
||
For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. |
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,84 @@ | ||
# Contributing | ||
|
||
Thanks for being willing to contribute! | ||
|
||
Is this **your first time** contributing to a different project? You might be interested in learning more about the workflow in [this free course](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github). | ||
|
||
## Project setup | ||
|
||
1. Fork and clone the repo | ||
2. Run `npm install` to install dependencies | ||
3. Run `npm run validate` to validate the installation | ||
4. Create a branch for your PR with `git checkout -b pr/your-branch-name` | ||
|
||
If you want to transpile and build the project, run `npm run build` (minified, production build) or `npm run dev` to compile and watch for file changes during development. | ||
|
||
> Tip: Keep your `master` branch pointing at the original repository and make | ||
> pull requests from branches on your fork. To do this, run: | ||
> | ||
> ``` | ||
> git remote add upstream https://github.com/andreasremdt/simple-translator.git | ||
> git fetch upstream | ||
> git branch --set-upstream-to=upstream/master master | ||
> ``` | ||
> | ||
> This will add the original repository as a "remote" called "upstream," Then | ||
> fetch the git information from that remote, then set your local `master` | ||
> branch to use the upstream master branch whenever you run `git pull`. Then you | ||
> can make all of your pull request branches based on this `master` branch. | ||
> Whenever you want to update your version of `master`, do a regular `git pull`. | ||
## Committing and pushing changes | ||
Please make sure to run the tests before you commit your changes. You can run `npm run validate` which will format, test, and lint the code. You won't be able to commit without all of these 3 passing. | ||
This project follows the [Karma Convention](https://karma-runner.github.io/4.0/dev/git-commit-msg.html). | ||
### Short form (only subject line) | ||
``` | ||
<type>(<scope>): <subject> | ||
``` | ||
### Long form (with body) | ||
``` | ||
<type>(<scope>): <subject> | ||
<BLANK LINE> | ||
<body> | ||
``` | ||
#### `<type>` | ||
Allowed `<type>` values: | ||
- **feat** (new feature) | ||
- **fix** (bug fix) | ||
- **docs** (changes to documentation) | ||
- **style** (formatting, missing semi colons, etc; no code change) | ||
- **refactor** (refactoring production code) | ||
- **test** (adding missing tests, refactoring tests; no production code change) | ||
- **chore** (updating rollup etc; no production code change) | ||
#### `<scope>` | ||
One word, maxim two connected by dash, describing the area the changes affect. Example values: | ||
- build | ||
- translator | ||
- utils | ||
- etc. | ||
#### `<subject>` | ||
- Use imperative, present tense: _change_ not _changed_ nor _changes_ or | ||
_changing_ | ||
- Do not capitalize first letter | ||
- Do not append dot (.) at the end | ||
## Help Needed | ||
Please checkout the [the open issues](https://github.com/andreasremdt/simple-translator/issues). | ||
Also, please watch the repo and respond to questions/bug reports/feature | ||
requests. Thanks! |
Oops, something went wrong.