Skip to content

Commit

Permalink
Fixes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Feb 18, 2024
1 parent d5e2a93 commit 7fcbe53
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 101 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@ module.exports = {
-->

### __WORK IN PROGRESS__
- (kleinOr) Keeps indentation of io-package
- (kleinOr/Apollon77) Detects and keeps space indentation of io-package
- (Steiger04) Fix handling of dot keys for esbuild
- (Steiger04) Update esbuild and adjust watch mode
- (Steiger04) process.env.NODE_ENV is now also available server side
-
### 1.2.0 (2022-10-23)
- (Grizzlebee) only translate linkText from messages if existent
- (Apollon77) Add ukrainian as language for translations
Expand Down
3 changes: 2 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export function getIndentation(text: string): number {
const lines = text.split(/\r?\n/);
const fileStartLine = lines.findIndex((line) => line.startsWith("{"));
if (fileStartLine !== -1 && lines.length > fileStartLine) {
const matches = lines[fileStartLine + 1].match(/^\s*/);
const matches = lines[fileStartLine + 1].match(/^[ ]+/);
console.log(matches);
if (matches && matches.length >= 1) {
return matches[0].length;
}
Expand Down
110 changes: 55 additions & 55 deletions test/data/continue-translate-io-package/expected/io-package.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
{
"common": {
"news": {
"1.0.1": {
"en": "Next version",
"de": "Mock translation of 'Next version' to 'de'",
"ru": "Mock translation of 'Next version' to 'ru'",
"pt": "Mock translation of 'Next version' to 'pt'",
"nl": "Mock translation of 'Next version' to 'nl'",
"fr": "Mock translation of 'Next version' to 'fr'",
"it": "Mock translation of 'Next version' to 'it'",
"es": "Mock translation of 'Next version' to 'es'",
"pl": "Mock translation of 'Next version' to 'pl'",
"uk": "Mock translation of 'Next version' to 'uk'",
"zh-cn": "Mock translation of 'Next version' to 'zh-cn'"
},
"1.0.0": {
"en": "Initial version",
"de": "My translation of 'Initial version' to 'de'",
"ru": "My translation of 'Initial version' to 'ru'",
"pt": "My translation of 'Initial version' to 'pt'",
"nl": "My translation of 'Initial version' to 'nl'",
"fr": "My translation of 'Initial version' to 'fr'",
"it": "My translation of 'Initial version' to 'it'",
"es": "My translation of 'Initial version' to 'es'",
"pl": "My translation of 'Initial version' to 'pl'",
"zh-cn": "My translation of 'Initial version' to 'zh-cn'",
"uk": "Mock translation of 'Initial version' to 'uk'"
}
},
"titleLang": {
"en": "My title",
"de": "My translation of 'My title' to 'de'",
"ru": "My translation of 'My title' to 'ru'",
"pt": "My translation of 'My title' to 'pt'",
"nl": "My translation of 'My title' to 'nl'",
"fr": "My translation of 'My title' to 'fr'",
"it": "My translation of 'My title' to 'it'",
"es": "My translation of 'My title' to 'es'",
"pl": "My translation of 'My title' to 'pl'",
"zh-cn": "My translation of 'My title' to 'zh-cn'",
"uk": "Mock translation of 'My title' to 'uk'"
},
"desc": {
"en": "My description",
"de": "My translation of 'My description' to 'de'",
"ru": "My translation of 'My description' to 'ru'",
"pt": "My translation of 'My description' to 'pt'",
"nl": "My translation of 'My description' to 'nl'",
"fr": "My translation of 'My description' to 'fr'",
"it": "My translation of 'My description' to 'it'",
"es": "My translation of 'My description' to 'es'",
"pl": "My translation of 'My description' to 'pl'",
"zh-cn": "My translation of 'My description' to 'zh-cn'",
"uk": "Mock translation of 'My description' to 'uk'"
}
"common": {
"news": {
"1.0.1": {
"en": "Next version",
"de": "Mock translation of 'Next version' to 'de'",
"ru": "Mock translation of 'Next version' to 'ru'",
"pt": "Mock translation of 'Next version' to 'pt'",
"nl": "Mock translation of 'Next version' to 'nl'",
"fr": "Mock translation of 'Next version' to 'fr'",
"it": "Mock translation of 'Next version' to 'it'",
"es": "Mock translation of 'Next version' to 'es'",
"pl": "Mock translation of 'Next version' to 'pl'",
"uk": "Mock translation of 'Next version' to 'uk'",
"zh-cn": "Mock translation of 'Next version' to 'zh-cn'"
},
"1.0.0": {
"en": "Initial version",
"de": "My translation of 'Initial version' to 'de'",
"ru": "My translation of 'Initial version' to 'ru'",
"pt": "My translation of 'Initial version' to 'pt'",
"nl": "My translation of 'Initial version' to 'nl'",
"fr": "My translation of 'Initial version' to 'fr'",
"it": "My translation of 'Initial version' to 'it'",
"es": "My translation of 'Initial version' to 'es'",
"pl": "My translation of 'Initial version' to 'pl'",
"zh-cn": "My translation of 'Initial version' to 'zh-cn'",
"uk": "Mock translation of 'Initial version' to 'uk'"
}
},
"titleLang": {
"en": "My title",
"de": "My translation of 'My title' to 'de'",
"ru": "My translation of 'My title' to 'ru'",
"pt": "My translation of 'My title' to 'pt'",
"nl": "My translation of 'My title' to 'nl'",
"fr": "My translation of 'My title' to 'fr'",
"it": "My translation of 'My title' to 'it'",
"es": "My translation of 'My title' to 'es'",
"pl": "My translation of 'My title' to 'pl'",
"zh-cn": "My translation of 'My title' to 'zh-cn'",
"uk": "Mock translation of 'My title' to 'uk'"
},
"desc": {
"en": "My description",
"de": "My translation of 'My description' to 'de'",
"ru": "My translation of 'My description' to 'ru'",
"pt": "My translation of 'My description' to 'pt'",
"nl": "My translation of 'My description' to 'nl'",
"fr": "My translation of 'My description' to 'fr'",
"it": "My translation of 'My description' to 'it'",
"es": "My translation of 'My description' to 'es'",
"pl": "My translation of 'My description' to 'pl'",
"zh-cn": "My translation of 'My description' to 'zh-cn'",
"uk": "Mock translation of 'My description' to 'uk'"
}
}
}
86 changes: 43 additions & 43 deletions test/data/continue-translate-io-package/input/io-package.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
{
"common": {
"news": {
"1.0.1": {
"en": "Next version"
},
"1.0.0": {
"en": "Initial version",
"de": "My translation of 'Initial version' to 'de'",
"ru": "My translation of 'Initial version' to 'ru'",
"pt": "My translation of 'Initial version' to 'pt'",
"nl": "My translation of 'Initial version' to 'nl'",
"fr": "My translation of 'Initial version' to 'fr'",
"it": "My translation of 'Initial version' to 'it'",
"es": "My translation of 'Initial version' to 'es'",
"pl": "My translation of 'Initial version' to 'pl'",
"zh-cn": "My translation of 'Initial version' to 'zh-cn'"
}
},
"titleLang": {
"en": "My title",
"de": "My translation of 'My title' to 'de'",
"ru": "My translation of 'My title' to 'ru'",
"pt": "My translation of 'My title' to 'pt'",
"nl": "My translation of 'My title' to 'nl'",
"fr": "My translation of 'My title' to 'fr'",
"it": "My translation of 'My title' to 'it'",
"es": "My translation of 'My title' to 'es'",
"pl": "My translation of 'My title' to 'pl'",
"zh-cn": "My translation of 'My title' to 'zh-cn'"
},
"desc": {
"en": "My description",
"de": "My translation of 'My description' to 'de'",
"ru": "My translation of 'My description' to 'ru'",
"pt": "My translation of 'My description' to 'pt'",
"nl": "My translation of 'My description' to 'nl'",
"fr": "My translation of 'My description' to 'fr'",
"it": "My translation of 'My description' to 'it'",
"es": "My translation of 'My description' to 'es'",
"pl": "My translation of 'My description' to 'pl'",
"zh-cn": "My translation of 'My description' to 'zh-cn'"
}
}
"common": {
"news": {
"1.0.1": {
"en": "Next version"
},
"1.0.0": {
"en": "Initial version",
"de": "My translation of 'Initial version' to 'de'",
"ru": "My translation of 'Initial version' to 'ru'",
"pt": "My translation of 'Initial version' to 'pt'",
"nl": "My translation of 'Initial version' to 'nl'",
"fr": "My translation of 'Initial version' to 'fr'",
"it": "My translation of 'Initial version' to 'it'",
"es": "My translation of 'Initial version' to 'es'",
"pl": "My translation of 'Initial version' to 'pl'",
"zh-cn": "My translation of 'Initial version' to 'zh-cn'"
}
},
"titleLang": {
"en": "My title",
"de": "My translation of 'My title' to 'de'",
"ru": "My translation of 'My title' to 'ru'",
"pt": "My translation of 'My title' to 'pt'",
"nl": "My translation of 'My title' to 'nl'",
"fr": "My translation of 'My title' to 'fr'",
"it": "My translation of 'My title' to 'it'",
"es": "My translation of 'My title' to 'es'",
"pl": "My translation of 'My title' to 'pl'",
"zh-cn": "My translation of 'My title' to 'zh-cn'"
},
"desc": {
"en": "My description",
"de": "My translation of 'My description' to 'de'",
"ru": "My translation of 'My description' to 'ru'",
"pt": "My translation of 'My description' to 'pt'",
"nl": "My translation of 'My description' to 'nl'",
"fr": "My translation of 'My description' to 'fr'",
"it": "My translation of 'My description' to 'it'",
"es": "My translation of 'My description' to 'es'",
"pl": "My translation of 'My description' to 'pl'",
"zh-cn": "My translation of 'My description' to 'zh-cn'"
}
}
}
2 changes: 1 addition & 1 deletion test/data/new-translations/input/io-package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"common": {}
"common": {}
}
1 change: 1 addition & 0 deletions test/data/translate-io-package/input/io-package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

{
"common": {
"news": {
Expand Down

0 comments on commit 7fcbe53

Please sign in to comment.