Skip to content

Commit

Permalink
Merge pull request #398 from athombv/chore/generate-locales
Browse files Browse the repository at this point in the history
chore: generate locales
  • Loading branch information
RobinBol authored Jun 20, 2024
2 parents d319716 + 521f3c0 commit e32dabf
Show file tree
Hide file tree
Showing 31 changed files with 4,539 additions and 28 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/apply_locales.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Apply Locales

# About this workflow:
# It is triggered on created pull_requests with changes in the "generated_locales" folder. It will apply the locale files from the "generated_locales" folder and commit the changes to the repository.

# GitHub repo configuration:
# 1. Go to Manage access and add 'Github Actions' team with role: admin.
# 2. If you have protected branches, go to Branches > edit protected branch > enable 'Restrict who can push to
# matching branches' and add the 'athombv/github-actions' team.

# Note: make sure to commit package-lock.json, this is needed for `npm ci`.

on:
pull_request:
paths:
- "generated_locales/**"

jobs:
apply_locales:
name: Apply Locales

# Only run this job if initiator is not the Homey Github Actions Bot to prevent loops
if: github.actor != 'homey-bot'

runs-on: ubuntu-latest
steps:
# Checks out the current repository.
- name: Checkout git repository
uses: actions/checkout@v3
with:
# The token below is only necessary if you want to push the version bump to a protected branch
token: ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}

# Set git config to reflect Homey Github Actions Bot user
- name: Set up HomeyGithubActionsBot git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "Homey Github Actions Bot"
# Configures a Node.js environment.
- name: Set up node 12 environment
uses: actions/setup-node@v1
with:
node-version: "12"

- name: Install dependencies
run: npm ci

- name: Apply Locales
run: node ./scripts/apply-locale-files.js

- name: Commit and push applied locales
run: |
git add . || echo "No changes due to applying locales."
git commit -m "ci: applied locales" || echo "No changes to commit."
git push origin HEAD:${{ github.event.pull_request.head.ref }}
60 changes: 60 additions & 0 deletions .github/workflows/generate_locales.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Generate Locales

# About this workflow:
# It is triggered on push events to master and develop with changes in the "assets" folder. It will generate locale files from the assets and commit the changes to the repository.

# GitHub repo configuration:
# 1. Go to Manage access and add 'Github Actions' team with role: admin.
# 2. If you have protected branches, go to Branches > edit protected branch > enable 'Restrict who can push to
# matching branches' and add the 'athombv/github-actions' team.

# Note: make sure to commit package-lock.json, this is needed for `npm ci`.

on:
workflow_dispatch:
push:
branches:
- "master"
- "develop"
paths:
- "assets/**"

jobs:
generate_locales:
name: Generate Locales

# Only run this job if initiator is not the Homey Github Actions Bot to prevent loops
if: github.actor != 'homey-bot'

runs-on: ubuntu-latest
steps:
# Checks out the current repository.
- name: Checkout git repository
uses: actions/checkout@v3
with:
# The token below is only necessary if you want to push the version bump to a protected branch
token: ${{ secrets.HOMEY_GITHUB_ACTIONS_BOT_PERSONAL_ACCESS_TOKEN }}

# Set git config to reflect Homey Github Actions Bot user
- name: Set up HomeyGithubActionsBot git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "Homey Github Actions Bot"
# Configures a Node.js environment.
- name: Set up node 12 environment
uses: actions/setup-node@v1
with:
node-version: "12"

- name: Install dependencies
run: npm ci

- name: Generate Locales
run: node ./scripts/generate-locale-files.js

- name: Commit and push generated locales
run: |
git add . || echo "No changes due to generated locales."
git commit -m "ci: generated locales" || echo "No changes to commit."
git push
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
generated_locales/*
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ This library can, among other things:


See `/examples/` for how-to usage.

## Translations

This library contains translations in the following files:
- `./assets/app/permissions.json`
- `./assets/capability/capabilities/<capability_id>.json`
- `./assets/device/classes/<device_class_id>.json`

These files are automatically parsed to language specific locale files in `./generated_locales`. The generated locales should not be edited manually, always edit the original files as listed above. Commits to master or develop with changes to the files above will trigger a [GitHub Action](.github/workflows/generate_locales.yml) that [re-generates](scripts/generate-locale-files.js) the locales and commits the result. Incoming PRs with changes to `./generated_locales` will trigger a [GitHub Action](.github/workflows/apply_locales.yml) that [applies](scripts/apply-locale-files.js) the updated generated locales to the files listed above.

> Note: when adding new languages to the files listed above, make sure to add the `./generated_locales/<new_language_code>.json` file manually so that the [script that generates the locales](scripts/generate-locale-files.js) will pick it up.
7 changes: 0 additions & 7 deletions assets/capability/capabilities/alarm_smoke.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"da": "Røgalarm",
"ru": "Сигнал дыма",
"pl": "Alarm przeciwdymny"

},
"desc": {
"en": "True when smoke has been detected",
Expand All @@ -26,7 +25,6 @@
"da": "Sandt, når røg er blevet opdaget",
"ru": "Верно при обнаружении дыма",
"pl": "Adekwatny, kiedy wykryty zostanie dym"

},
"insights": true,
"insightsTitleTrue": {
Expand All @@ -41,7 +39,6 @@
"da": "Røgalarm blev aktiveret",
"ru": "Сигнал дыма включен",
"pl": "Alarm przeciwdymny włączony"

},
"insightsTitleFalse": {
"en": "Smoke alarm turned off",
Expand All @@ -55,7 +52,6 @@
"da": "Røgalarm blev deaktiveret",
"ru": "Сигнал дыма выключен",
"pl": "Alarm przeciwdymny wyłączony"

},
"getable": true,
"setable": false,
Expand All @@ -77,7 +73,6 @@
"da": "Røgalarmen blev aktiveret",
"ru": "Сигнал дыма включен",
"pl": "Alarm przeciwdymny włączony"

}
},
{
Expand All @@ -94,7 +89,6 @@
"da": "Røgalarmen blev deaktiveret",
"ru": "Сигнал дыма выключен",
"pl": "Alarm przeciwdymny wyłączony"

}
}
],
Expand All @@ -113,7 +107,6 @@
"da": "Røgalarmen er !{{tændt|slukket}}",
"ru": "Сигнал дыма !{{вкл.|выкл.}}",
"pl": "Alarm przeciwdymny !{{włączony|wyłączony}}"

}
}
]
Expand Down
2 changes: 1 addition & 1 deletion assets/capability/capabilities/garagedoor_closed.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@
}
]
}
}
}
4 changes: 0 additions & 4 deletions assets/capability/capabilities/light_mode.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"da": "Lystilstand",
"ru": "Режим света",
"pl": "Tryb oświetlenia"

},
"desc": {
"en": "Switch between color or temperature mode",
Expand All @@ -26,7 +25,6 @@
"da": "Skift mellem farve- eller temperaturtilstand",
"ru": "Переключение между цветовым или температурным режимом",
"pl": "Przełączaj między trybem barwy lub temperatury"

},
"values": [
{
Expand All @@ -43,7 +41,6 @@
"da": "Farve",
"ru": "Цвет",
"pl": "Barwa"

}
},
{
Expand All @@ -60,7 +57,6 @@
"da": "Temperatur",
"ru": "Температура",
"pl": "Temperatura"

}
}
],
Expand Down
2 changes: 0 additions & 2 deletions assets/capability/capabilities/light_saturation.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"da": "Farvemætning",
"ru": "Насыщенность цвета",
"pl": "Nasycenie barwy"

},
"min": 0,
"chartType": "stepLine",
Expand All @@ -36,7 +35,6 @@
"da": "Indstil farvemætningen",
"ru": "Установить насыщенность",
"pl": "Ustaw nasycenie"

},
"args": [
{
Expand Down
2 changes: 0 additions & 2 deletions assets/capability/capabilities/measure_gust_angle.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"da": "Vindretning",
"ru": "Угол порывов ветра",
"pl": "Kąt porywu wiatru"

},
"units": {
"en": "°"
Expand All @@ -30,7 +29,6 @@
"da": "Vindretning i grader (°)",
"ru": "Угол порывов ветра в градусах (°)",
"pl": "Kąt porywu wiatru w stopniach (°)"

},
"chartType": "stepLine",
"decimals": 2,
Expand Down
2 changes: 1 addition & 1 deletion assets/capability/capabilities/measure_gust_strength.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
}
]
}
}
}
2 changes: 1 addition & 1 deletion assets/capability/capabilities/onoff.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,4 @@
}
]
}
}
}
2 changes: 1 addition & 1 deletion assets/device/classes/coffeemachine.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"ru": "Используйте этот класс устройств для кофемашин.",
"pl": "Użyj tej klasy urządzeń dla ekspresów do kawy."
}
}
}
2 changes: 0 additions & 2 deletions assets/device/classes/garagedoor.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
"da": "Garageport",
"ru": "Дверь гаража",
"pl": "Brama garażowa"

},
"description": {
"en": "Use this device class for garage doors, usually together with the `garagedoor_closed` capability.",
"ru": "Используйте этот класс устройств для дверей гаража, обычно вместе с функцией `garagedoor_closed`.",
"pl": "Użyj tej klasy urządzeń dla bram garażowych, zwykle razem ze zdolnością „garagedoor_closed”."

}
}
2 changes: 0 additions & 2 deletions assets/device/classes/light.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"da": "Lys",
"ru": "Лампа",
"pl": "Oświetlenie"

},
"description": {
"en": "Use this device class for lights, usually together with the `onoff`, `dim` and `light_*` capabilities.",
Expand All @@ -24,6 +23,5 @@
"da": "Brug denne enhedsklasse til lys, normalt sammen med `onoff`, `dim` og `light_*` funktionerne.",
"ru": "Используйте этот класс устройств для ламп, обычно вместе с функциями `onoff`,`dim` и `light_ *`.",
"pl": "Użyj tej klasy urządzeń dla oświetlenia, zwykle razem ze zdolnościami `onoff`, `dim` oraz `light_*`."

}
}
3 changes: 0 additions & 3 deletions assets/device/classes/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"da": "Relæ",
"ru": "Узел",
"pl": "Przekaźnik"

},
"description": {
"en": "Use this device class for relays, which are connected to another device.",
Expand All @@ -24,7 +23,6 @@
"da": "Brug denne enhedsklasse til relæer, som er koblet til en anden enhed.",
"ru": "Используйте этот класс устройств для узлов, которые подключены к другому устройству.",
"pl": "Użyj tej klasy urządzeń dla przekaźników niepołączonych z żadnym innym urządzeniem."

},
"virtualTitle": {
"en": "What's connected?",
Expand All @@ -38,7 +36,6 @@
"da": "Hvad er tilkoblet?",
"ru": "Что подключено?",
"pl": "Co jest połączone?"

},
"allowedVirtual": [
"garagedoor",
Expand Down
2 changes: 0 additions & 2 deletions assets/device/classes/solarpanel.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
"da": "Solpanel",
"ru": "Солнечная панель",
"pl": "Panel fotowoltaiczny"

},
"description": {
"en": "Use this device class for solar panels.",
"es": "Utiliza esta clase de dispositivo para los paneles solares.",
"da": "Brug denne enhedsklasse til solpaneler.",
"ru": "Используйте этот класс устройств для солнечных панелей.",
"pl": "Użyj tej klasy urządzeń dla paneli fotowoltaicznych."

}
}
Loading

0 comments on commit e32dabf

Please sign in to comment.