Skip to content

Commit

Permalink
Add documentation for publishing packages (#146)
Browse files Browse the repository at this point in the history
* docs: add documentation for publishing

* docs: fix indentation

* Update PUBLISH.md

* Update PUBLISH.md

* Update PUBLISH.md

* Update PUBLISH.md
  • Loading branch information
Matwog authored Sep 28, 2022
1 parent c4f79e3 commit d898626
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
48 changes: 48 additions & 0 deletions PUBLISH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# How to publish packages

1. Enter the master branch and check that pipelines are green

```bash
git checkout master
```

2. reset your current master branch to the latest state by

```bash
git fetch
git reset origin/master --hard
```

3. Checkout a new branch that we'll release versions from

```bash
git checkout -b release-new-version-[a-b-c]
```

4. Start the publishing procedure (\*\*)
1. Check the current version using `npm version`
2. Update the version you would to like to publish `npm version [version] # version -> major, minor, patch ... version`
3. Push the branch `git push`


5. Publish the package.

```bash
npm publish
```

6. Open a PR of your release branch and get an approval to finally merge the release it into master

```bash
git checkout master && git reset origin/master --hard
git merge origin/release-new-version-[a-b-c] --ff-only
git push origin master
```

7. Create a release note (Use template from older release tags https://github.com/signavio/i18n/releases)

1. Add summary: Describe the changes/packages of this release
2. Add the release tag created in the previous steps: (v1.2.0)
3. Add title: #<release-number> release of i18n packages

8. Great Job! You've done it. 🎉
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ Create the file `.i18nrc` and add a configuration object for gettext message ext
}
```


**IMPORTANT:** when the second command line argument is passed to the `i18n-extract` command, it will overwrite the `fileName` field of the `.i18nrc` config.
**IMPORTANT:** when the second command line argument is passed to the `i18n-extract` command, it will overwrite the `fileName` field of the `.i18nrc` config.

More available options are documented here: https://github.com/getsentry/babel-gettext-extractor

Expand Down Expand Up @@ -166,7 +165,9 @@ i18n('I want _this_ to be **bold**', {
```

### Replacements

#### Extrtaction

Sometimes there may be cases when you need to rename several entities across the whole project, but keep the both versions of translations and show them based on the feature flag.
Doing that manually could be laborious, that's why `i18n-extract` supports a path to the replacements json as an optional third command line argument.

Expand All @@ -184,7 +185,7 @@ Values of each context are objects for the original translation strings and the

```json
{
"some context" : {
"some context": {
"Old translation": "New translation",
"Old translation2": "New translation2"
}
Expand All @@ -195,22 +196,22 @@ If the translation does not have the context, then it should be stored in the `"

```json
{
"" : {
"Old translation": "New translation without context",
"": {
"Old translation": "New translation without context"
},
"some context": {
"Old translation": "New translation with some context",
"Old translation": "New translation with some context"
}
}
```

Having the original JS code:

Having the original JS code:
```javascript
// translators: comment 1
i18n('Old translation');
i18n('Old translation')
// translators: comment 2
i18n('Old translation2');
i18n('Old translation2')
```

The .pot file will have the following content
Expand All @@ -235,6 +236,7 @@ msgstr ""
```

#### Usage

To use the replacements instead of the old strings in runtime pass the same replecements object which was used in the extraction step to the `init` function:

```javascript
Expand All @@ -252,6 +254,9 @@ init(getLangLoader, config, replacements).then(() => {
})
```

### Publishing Packages

Read the following [guide](PUBLISH.md) to publish packages of the i18n repository

[build-badge]: https://circleci.com/gh/signavio/i18n/tree/master.svg?style=shield&circle-token=:circle-token
[build]: https://circleci.com/gh/signavio/i18n/tree/master
Expand Down

0 comments on commit d898626

Please sign in to comment.