-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VSCode Extension uses JSON with simple map id to source string. The source files are package.nls.json and l10n/bundle.l10n.json. Also see docs: https://github.com/microsoft/vscode-extension-samples/tree/main/l10n-sample
- Loading branch information
Showing
37 changed files
with
456 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
cli/src/main/java/com/box/l10n/mojito/cli/filefinder/file/VSCodeFileType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.box.l10n.mojito.cli.filefinder.file; | ||
|
||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.BASE_NAME; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.DOT; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.FILE_EXTENSION; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.LOCALE; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.PARENT_PATH; | ||
|
||
import com.box.l10n.mojito.cli.filefinder.locale.AnyLocaleType; | ||
|
||
/** | ||
* https://github.com/microsoft/vscode-extension-samples/tree/main/l10n-sample | ||
* | ||
* @author jaurambault | ||
*/ | ||
public class VSCodeFileType extends JSONFileType { | ||
|
||
public VSCodeFileType() { | ||
this.baseNamePattern = "(package\\.nls|bundle\\.l10n)"; | ||
this.sourceFilePatternTemplate = | ||
"{" + PARENT_PATH + "}{" + BASE_NAME + "}" + DOT + "{" + FILE_EXTENSION + "}"; | ||
this.targetFilePatternTemplate = | ||
"{" | ||
+ PARENT_PATH | ||
+ "}{" | ||
+ BASE_NAME | ||
+ "}" | ||
+ DOT | ||
+ "{" | ||
+ LOCALE | ||
+ "}" | ||
+ DOT | ||
+ "{" | ||
+ FILE_EXTENSION | ||
+ "}"; | ||
this.localeType = new AnyLocaleType(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
cli/src/test/java/com/box/l10n/mojito/cli/filefinder/file/VSCodeFileTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.box.l10n.mojito.cli.filefinder.file; | ||
|
||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.BASE_NAME; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.FILE_EXTENSION; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.LOCALE; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.PARENT_PATH; | ||
|
||
import com.box.l10n.mojito.cli.filefinder.FilePattern; | ||
import java.util.regex.Matcher; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class VSCodeFileTypeTest { | ||
|
||
@Test | ||
public void testSourcePattern() { | ||
VSCodeFileType vSCodeFileType = new VSCodeFileType(); | ||
FilePattern sourceFilePattern = vSCodeFileType.getSourceFilePattern(); | ||
Matcher matcher = sourceFilePattern.getPattern().matcher("/l10n/bundle.l10n.json"); | ||
Assert.assertTrue(matcher.matches()); | ||
Assert.assertEquals("/l10n/", matcher.group(PARENT_PATH)); | ||
Assert.assertEquals("bundle.l10n", matcher.group(BASE_NAME)); | ||
Assert.assertEquals("json", matcher.group(FILE_EXTENSION)); | ||
} | ||
|
||
@Test | ||
public void testSourcePatternPakcage() { | ||
VSCodeFileType vSCodeFileType = new VSCodeFileType(); | ||
FilePattern sourceFilePattern = vSCodeFileType.getSourceFilePattern(); | ||
Matcher matcher = sourceFilePattern.getPattern().matcher("package.nls.json"); | ||
Assert.assertTrue(matcher.matches()); | ||
Assert.assertEquals("", matcher.group(PARENT_PATH)); | ||
Assert.assertEquals("package.nls", matcher.group(BASE_NAME)); | ||
Assert.assertEquals("json", matcher.group(FILE_EXTENSION)); | ||
} | ||
|
||
@Test | ||
public void testTargetPattern() { | ||
VSCodeFileType vSCodeFileType = new VSCodeFileType(); | ||
Matcher matcher = | ||
vSCodeFileType.getTargetFilePattern().getPattern().matcher("/l10n/bundle.l10n.fr.json"); | ||
Assert.assertTrue(matcher.matches()); | ||
Assert.assertEquals("fr", matcher.group(LOCALE)); | ||
Assert.assertEquals("/l10n/", matcher.group(PARENT_PATH)); | ||
Assert.assertEquals("bundle.l10n", matcher.group(BASE_NAME)); | ||
Assert.assertEquals("json", matcher.group(FILE_EXTENSION)); | ||
} | ||
|
||
@Test | ||
public void testTargetPatternBcp47() { | ||
VSCodeFileType vSCodeFileType = new VSCodeFileType(); | ||
Matcher matcher = | ||
vSCodeFileType.getTargetFilePattern().getPattern().matcher("/l10n/bundle.l10n.fr-FR.json"); | ||
Assert.assertTrue(matcher.matches()); | ||
Assert.assertEquals("fr-FR", matcher.group(LOCALE)); | ||
Assert.assertEquals("/l10n/", matcher.group(PARENT_PATH)); | ||
Assert.assertEquals("bundle.l10n", matcher.group(BASE_NAME)); | ||
Assert.assertEquals("json", matcher.group(FILE_EXTENSION)); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...calizedAssetCommandTest_IO/importJsonVSCodeExtension/expected/l10n/bundle.l10n.fr-CA.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...calizedAssetCommandTest_IO/importJsonVSCodeExtension/expected/l10n/bundle.l10n.fr-FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...calizedAssetCommandTest_IO/importJsonVSCodeExtension/expected/l10n/bundle.l10n.ja-JP.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "100文字の説明:", | ||
"15_min_duration": "15分", | ||
"1_day_duration": "1日", | ||
"1_hour_duration": "1時間", | ||
"1_month_duration": "1か月" | ||
} |
7 changes: 7 additions & 0 deletions
7
...ortLocalizedAssetCommandTest_IO/importJsonVSCodeExtension/expected/package.nls.fr-CA.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...ortLocalizedAssetCommandTest_IO/importJsonVSCodeExtension/expected/package.nls.fr-FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...ortLocalizedAssetCommandTest_IO/importJsonVSCodeExtension/expected/package.nls.ja-JP.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "100文字の説明:", | ||
"15_min_duration": "15分", | ||
"1_day_duration": "1日", | ||
"1_hour_duration": "1時間", | ||
"1_month_duration": "1か月" | ||
} |
7 changes: 7 additions & 0 deletions
7
...LocalizedAssetCommandTest_IO/importJsonVSCodeExtension/input/source/l10n/bundle.l10n.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "100 character description:", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 day", | ||
"1_hour_duration": "1 hour", | ||
"1_month_duration": "1 month" | ||
} |
7 changes: 7 additions & 0 deletions
7
...mportLocalizedAssetCommandTest_IO/importJsonVSCodeExtension/input/source/package.nls.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "100 character description:", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 day", | ||
"1_hour_duration": "1 hour", | ||
"1_month_duration": "1 month" | ||
} |
7 changes: 7 additions & 0 deletions
7
...etCommandTest_IO/importJsonVSCodeExtension/input/translations/l10n/bundle.l10n.fr-CA.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...etCommandTest_IO/importJsonVSCodeExtension/input/translations/l10n/bundle.l10n.fr-FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...etCommandTest_IO/importJsonVSCodeExtension/input/translations/l10n/bundle.l10n.ja-JP.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "100文字の説明:", | ||
"15_min_duration": "15分", | ||
"1_day_duration": "1日", | ||
"1_hour_duration": "1時間", | ||
"1_month_duration": "1か月" | ||
} |
7 changes: 7 additions & 0 deletions
7
...edAssetCommandTest_IO/importJsonVSCodeExtension/input/translations/package.nls.fr-CA.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...edAssetCommandTest_IO/importJsonVSCodeExtension/input/translations/package.nls.fr-FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...edAssetCommandTest_IO/importJsonVSCodeExtension/input/translations/package.nls.ja-JP.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "100文字の説明:", | ||
"15_min_duration": "15分", | ||
"1_day_duration": "1日", | ||
"1_hour_duration": "1時間", | ||
"1_month_duration": "1か月" | ||
} |
7 changes: 7 additions & 0 deletions
7
...nd/PullCommandTest_IO/pullJsonVSCodeExtension/expected/target/l10n/bundle.l10n.fr-CA.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...nd/PullCommandTest_IO/pullJsonVSCodeExtension/expected/target/l10n/bundle.l10n.fr-FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...nd/PullCommandTest_IO/pullJsonVSCodeExtension/expected/target/l10n/bundle.l10n.ja-JP.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "100文字の説明:", | ||
"15_min_duration": "15分", | ||
"1_day_duration": "1日", | ||
"1_hour_duration": "1時間", | ||
"1_month_duration": "1か月" | ||
} |
7 changes: 7 additions & 0 deletions
7
...command/PullCommandTest_IO/pullJsonVSCodeExtension/expected/target/package.nls.fr-CA.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...command/PullCommandTest_IO/pullJsonVSCodeExtension/expected/target/package.nls.fr-FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "Description de 100 caractères :", | ||
"15_min_duration": "15 min", | ||
"1_day_duration": "1 jour", | ||
"1_hour_duration": "1 heure", | ||
"1_month_duration": "1 mois" | ||
} |
7 changes: 7 additions & 0 deletions
7
...command/PullCommandTest_IO/pullJsonVSCodeExtension/expected/target/package.nls.ja-JP.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"100_character_description_": "100文字の説明:", | ||
"15_min_duration": "15分", | ||
"1_day_duration": "1日", | ||
"1_hour_duration": "1時間", | ||
"1_month_duration": "1か月" | ||
} |
Oops, something went wrong.