Skip to content

Commit

Permalink
Translation fixes (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Oct 10, 2021
1 parent 3efe20e commit db2db16
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ReleaseActions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
release:
types: ["published"]

env:
NODE_VERSION: 14
PYTHON_VERSION: "3.x"

jobs:
deploy:
runs-on: ubuntu-latest
Expand All @@ -15,7 +19,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2.2.2
with:
python-version: "3.x"
python-version: ${{ env.PYTHON_VERSION }}

- name: Set up Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn

# Get updated translations
- name: Download Lokalise CLI
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/TestBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
branches:
- main

env:
NODE_VERSION: 14

jobs:
build_frontend:
name: Test build
Expand All @@ -17,6 +20,13 @@ jobs:
- uses: actions/checkout@v2
- name: Checkout submodules
uses: textbook/git-checkout-submodule-action@master

- name: Set up Node ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn

- name: Install dependencies
run: script/bootstrap
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion script/gulp/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function recursiveFlatten(prefix, data) {
...recursiveFlatten(prefix + key + ".", data[key]),
};
} else {
output[prefix + key] = data[key];
output[prefix + key] = data[key].replace(/'{/g, "''{").replace(/}'/g, "}''");
}
});
return Object.fromEntries(Object.entries(output).sort());
Expand Down
2 changes: 1 addition & 1 deletion src/localize/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
"title": "Pending restart",
"content": "You have {number} {pluralWording} for which a restart of Home Assistant is required. You can do that from the 'Server management' section under the configuration part of Home Assistant UI."
},
"removed_repository": "Removed repository ''{repository}''"
"removed_repository": "Removed repository '{repository}'"
},
"intro": "Updates and important messages will show here if there are any",
"information": "Information",
Expand Down
5 changes: 2 additions & 3 deletions src/localize/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ export function localize(language: string, string: string, replace?: Record<stri
.replace("-", "_");

if (!languages[lang]) {
lang = DEFAULT_LANGUAGE;

if (!warnings.language?.includes(lang)) {
warnings.language.push(lang);
logger.warn(
`Language '${lang.replace(
"_",
"-"
)}' is not added to HACS. https://hacs.xyz/docs/developer/translation`
)}' is not added to HACS, using '${DEFAULT_LANGUAGE}' instead. https://hacs.xyz/docs/developer/translation`
);
}
lang = DEFAULT_LANGUAGE;
}

const translatedValue = languages[lang]?.[string] || languages[DEFAULT_LANGUAGE][string];
Expand Down

0 comments on commit db2db16

Please sign in to comment.