Skip to content

Commit

Permalink
Fixed a bug in the array iterator.
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist committed Nov 6, 2020
1 parent 412c910 commit b9482ad
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion __tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const expectedLocales = [
'sl', 'sm', 'sr-Cyrl', 'sr-Latn', 'sv', 'sw', 'ta',
'te', 'th', 'tlh-Latn', 'tlh-Piqd', 'to', 'tr', 'ty',
'uk', 'ur', 'vi', 'yua', 'yue', 'zh-Hans', 'zh-Hant'
]
];

test('API: get available translations correctly gets all locales', async () => {
const translations = await getAvailableTranslations();
Expand Down
10 changes: 9 additions & 1 deletion __tests__/resource-io.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { readFile, writeFile, buildXml, applyTranslations } from '../src/resource-io';
import { resolve } from 'path';
import { getLocaleName } from '../src/utils';

test('IO: read file correctly parses known XML', async () => {
const resourcePath = resolve(__dirname, './data/Test.en.resx');
Expand Down Expand Up @@ -79,4 +80,11 @@ test('IO: apply translations to Index.en.resx', async () => {
expect(resourceXml.root.data[1].value[0]).toEqual('Goodbye my friend');
expect(resourceXml.root.data[2].$.name).toEqual('SurveyTitle');
expect(resourceXml.root.data[2].value[0]).toEqual('I do not like surveys!');
});
});

test('IO: correctly gets local name.', () => {
const resourcePath = resolve(__dirname, './data/Index.en.resx');
const localName = getLocaleName(resourcePath, 'fr');

expect(localName).toEqual(resourcePath.replace('.en.resx', '.fr.resx'));
})
3 changes: 2 additions & 1 deletion dist/resource-translator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11632,7 +11632,8 @@ async function initiate() {
const resultSet = await api_1.translate(inputOptions, toLocales, translatableTextMap.text);
core_1.info(`Translation result:\n ${JSON.stringify(resultSet)}`);
if (resultSet) {
for (let locale in toLocales) {
for (let index = 0; index < toLocales.length; index++) {
const locale = toLocales[index];
const translations = resultSet[locale];
const clone = { ...resourceXml };
const result = resource_io_1.applyTranslations(clone, translations, translatableTextMap.ordinals);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ievangelist/resource-translator",
"version": "1.0.2-preview6",
"version": "1.0.2-preview7",
"preview": true,
"keywords": [
"github",
Expand Down
3 changes: 2 additions & 1 deletion src/resource-translator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export async function initiate() {
info(`Translation result:\n ${JSON.stringify(resultSet)}`);

if (resultSet) {
for (let locale in toLocales) {
for (let index = 0; index < toLocales.length; index ++) {
const locale = toLocales[index];
const translations = resultSet[locale];
const clone = { ...resourceXml };
const result = applyTranslations(clone, translations, translatableTextMap.ordinals);
Expand Down

0 comments on commit b9482ad

Please sign in to comment.