Skip to content

Commit

Permalink
Merge pull request #49 from Tanibox/1.6.0-localisation
Browse files Browse the repository at this point in the history
Ship it to Master
  • Loading branch information
bepitulaz authored Mar 31, 2019
2 parents 987a3fe + 96b51e2 commit 6b9083e
Show file tree
Hide file tree
Showing 92 changed files with 5,319 additions and 9,872 deletions.
13 changes: 7 additions & 6 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"presets": [
["env", { "modules": false }],
"stage-2"
["@babel/preset-env", {
"modules": false
}]
],
"plugins": [
"transform-runtime",
"transform-object-rest-spread",
["babel-plugin-root-import", { "rootPathSuffix": "resources/js", "rootPathPrefix": "@" }]
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-object-rest-spread"
],
"comments": false,
"env": {
"test": {
"presets": ["env", "stage-2"],
"presets": ["@babel/preset-env"],
"plugins": [ "istanbul" ]
}
}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.dll
*.so
*.dylib
tania-core

# Test binary, build with `go test -c`
*.test
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ before_install:
- tar xJf gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz
- export PATH=$(pwd)/gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf/bin:$PATH
- arm-linux-gnueabihf-gcc --version
- ./scripts/fetch_osxcross.sh
- bash scripts/fetch_osxcross.sh
- export PATH=~/osx_tools/bin:$PATH
- o64-clang --version && o64-clang++ --version

Expand All @@ -50,4 +50,4 @@ install:
- npm install -g npm@latest
- yarn

script: ./scripts/build_test.sh
script: bash scripts/build_test.sh
57 changes: 55 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
SHELL = /bin/bash
NODE_BINDIR = ./node_modules/.bin
export PATH := $(NODE_BINDIR):$(PATH)
LOGNAME ?= $(shell logname)

# adding the name of the user's login name to the template file, so that
# on a multi-user system several users can run this without interference
TEMPLATE_POT = ./languages/template.pot

# Where to find input files (it can be multiple paths).
INPUT_FILES = ./resources/js

# Where to write the files generated by this makefile.
OUTPUT_DIR = ./languages

# Available locales for the app.
LOCALES = en_GB id_ID hu_HU

# Name of the generated .po files for each available locale.
LOCALE_FILES ?= $(patsubst %,$(OUTPUT_DIR)/locale/app.po, $(LOCALES))

GETTEXT_SOURCES ?= $($(INPUT_FILES) 2> /dev/null)

.PHONY: all cover clean clean-osx clean-linux-arm clean-linux-amd64 clean-win64 \
osx linux-amd64 linux-arm windows fetch-dep run osxcross.bin
osx linux-amd64 linux-arm windows fetch-dep run osxcross.bin \
cleantranslations makemessages translations

all: osx linux-amd64 linux-arm windows


clean:
@[ -f tania.osx.amd64 ] && rm -f tania.osx.amd64 || true
@[ -f tania.linux.arm ] && rm -f tania.linux.arm || true
Expand Down Expand Up @@ -64,3 +87,33 @@ fetch-dep: Gopkg.toml Gopke.lock

run: main.go
go run $^

# Translation makefile
cleantranslations:
rm -f $(TEMPLATE_POT) $(OUTPUT_DIR)/translations.json

makemessages: $(TEMPLATE_POT)

translations: ./$(OUTPUT_DIR)/translations.json

# Create a main .pot template, then generate .po files for each available language.
# Thanx to Systematic: https://github.com/Polyconseil/systematic/blob/866d5a/mk/main.mk#L167-L183
$(TEMPLATE_POT): $(GETTEXT_SOURCES)
# Extract gettext strings from templates files and create a POT dictionary template.
node node_modules/vue-webpack-gettext/extract --output ./$(OUTPUT_DIR)/template.pot --src ./resources/js/
# Generate .po files for each available language.
@for lang in $(LOCALES); do \
export PO_FILE=$(OUTPUT_DIR)/locale/$$lang/LC_MESSAGES/app.po; \
mkdir -p $$(dirname $$PO_FILE); \
if [ -f $$PO_FILE ]; then \
echo "msgmerge --update $$PO_FILE $@"; \
msgmerge --lang=$$lang --update $$PO_FILE $@ || break ;\
else \
msginit --no-translator --locale=$$lang --input=$@ --output-file=$$PO_FILE || break ; \
msgattrib --no-wrap --no-obsolete -o $$PO_FILE $$PO_FILE || break; \
fi; \
done;

$(OUTPUT_DIR)/translations.json: $(LOCALE_FILES)
mkdir -p $(OUTPUT_DIR)
gettext-compile --output $@ $(LOCALE_FILES)
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
<img src="https://opencollective.com/tania/tiers/backer/badge.svg?label=backer&color=brightgreen" />
<img src="https://opencollective.com/tania/tiers/sponsor/badge.svg?label=sponsor&color=brightgreen" />
<a href="https://t.me/usetania"><img src="https://img.shields.io/badge/Telegram-blue.svg?logo=telegram&style=flat&label=chat%20on" alt="telegram"></a>
<img src="https://img.shields.io/badge/semver-1.5.1-green.svg?maxAge=2592000" alt="semver">
<img src="https://travis-ci.com/Tanibox/tania-core.svg?branch=master" alt="Build Status">
<img src="https://img.shields.io/badge/semver-1.6.0-green.svg?maxAge=2592000" alt="semver">
<a href="https://travis-ci.com/Tanibox/tania-core">
<img src="https://travis-ci.com/Tanibox/tania-core.svg?branch=master" alt="Build Status">
</a>
<a href="https://opensource.org/licenses/Apache-2.0" target="_blank"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
</div>

Expand All @@ -26,6 +28,7 @@ Download Tania for Windows x64 and Linux x64 on [the release page](https://githu
* [REST APIs](#rest-apis)
* [Roadmap](#roadmap)
* [Contributing to Tania](#contributing-to-tania)
* [Localisation](#localisation)
* [Support Us](#support-us)
* [Backers](#backers)
* [Sponsors](#sponsors)
Expand Down Expand Up @@ -96,6 +99,36 @@ We want to share our high-level details of our roadmap, so that others can see o

We welcome contributions, but request you to follow these [guidelines](contributing.md).

### Localisation

You can help us to localise Tania into your language by following these steps:

1. Copy `languages/template.pot` and paste it to `languages/locale` directory.
2. Rename it with your language locale code e.g: `en_AU.po`, `de_DE.po`, etc.
3. Fill `msgstr` key with your translation. You can edit the `.po` file by using text editor or PO Edit software.
4. Pull request your translation to the `master` branch.

### Build Tania localisation by yourself

**Note:** You will need to install GNU Gettext for your OS. Get it [here](https://www.gnu.org/software/gettext/).

You can build Tania in your language by changing the default language inside `resources/js/app.js`.

```
Vue.use(GetTextPlugin, {
availableLanguages: { // add your language here
en_GB: 'British English',
id_ID: 'Bahasa Indonesia',
hu_HU: 'Magyar Nyelv'
},
defaultLanguage: 'en_GB', // change this to your language
translations: translations,
silent: false
})
```

Then follow the instruction to [build Tania](#building-instructions).

## Support Us

You can become a backer or a sponsor for Tania through our [Open Collective page](https://opencollective.com/tania).
Expand Down
Loading

0 comments on commit 6b9083e

Please sign in to comment.