Skip to content

Commit

Permalink
WIP Add support for Plural String import
Browse files Browse the repository at this point in the history
initial version of the connector could only push/pull (maybe buggy), this is an attempt at supporting push translations too
  • Loading branch information
aurambaj committed Jun 14, 2024
1 parent 72cbf0e commit 3994937
Show file tree
Hide file tree
Showing 15 changed files with 404 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import com.box.l10n.mojito.entity.Locale;
import com.box.l10n.mojito.entity.Repository;
import com.box.l10n.mojito.service.locale.LocaleService;
import org.junit.Assume;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

/**
* @author jeanaurambault
Expand All @@ -19,6 +21,10 @@ public class ImportLocalizedAssetCommandTest extends CLITestBase {

@Autowired LocaleService localeService;

// TODO(ja) move in its own class
@Value("${test.phrase-client.projectId}")
String testProjectId;

@Test
public void importAndroidStrings() throws Exception {

Expand Down Expand Up @@ -92,6 +98,54 @@ public void importAndroidStringsPlural() throws Exception {
checkExpectedGeneratedResources();
}

@Test
public void importAndroidStringsPluralWithThirdPartySync() throws Exception {
Assume.assumeNotNull(testProjectId);

Repository repository = createTestRepoUsingRepoService();
repositoryService.addRepositoryLocale(repository, "ru-RU");

getL10nJCommander()
.run(
"push",
"-r",
repository.getName(),
"-s",
getInputResourcesTestDir("source").getAbsolutePath());

getL10nJCommander()
.run(
"import",
"-r",
repository.getName(),
"-s",
getInputResourcesTestDir("source").getAbsolutePath(),
"-t",
getInputResourcesTestDir("translations").getAbsolutePath());

getL10nJCommander()
.run(
"pull",
"-r",
repository.getName(),
"-s",
getInputResourcesTestDir("source").getAbsolutePath(),
"-t",
getTargetTestDir().getAbsolutePath());

getL10nJCommander()
.run(
"thirdparty-sync",
"-r",
repository.getName(),
"-p",
testProjectId,
"-a",
"PUSH,MAP_TEXTUNIT,PUSH_TRANSLATION,PULL");

checkExpectedGeneratedResources();
}

@Test
public void importMacStrings() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- The singular and plural form for Recipe Cook Time in hours -->
<plurals name="plural_recipe_cook_hours">
<item formatted="false" quantity="one">%1$,d heure à cuisiner</item>
<item formatted="false" quantity="other">%1$,d heures à cuisiner</item>
</plurals>

<!-- People, as a filter -->
<string name="people">Membres</string>

<plurals name="plural_collaborators_other">
<item formatted="false" quantity="one">%1$,d collaborateur</item>
<item formatted="false" quantity="other">%1$,d collaborateurs</item>
</plurals>

<!-- Header for the recipe ingredients with the ingredients countsection -->
<plurals name="pin_recipe_ingredients_with_count">
<item formatted="false" quantity="one">%1$d ingrédient</item>
<item formatted="false" quantity="other">%1$d ingrédients</item>
</plurals>

<!-- Delete a piece of content -->
<string name="delete_confirm">Supprimer</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- The singular and plural form for Recipe Cook Time in hours -->
<plurals name="plural_recipe_cook_hours">
<item formatted="false" quantity="one">%1$,d heure à cuisiner</item>
<item formatted="false" quantity="other">%1$,d heures à cuisiner</item>
</plurals>

<!-- People, as a filter -->
<string name="people">Membres</string>

<plurals name="plural_collaborators_other">
<item formatted="false" quantity="one">%1$,d collaborateur</item>
<item formatted="false" quantity="other">%1$,d collaborateurs</item>
</plurals>

<!-- Header for the recipe ingredients with the ingredients countsection -->
<plurals name="pin_recipe_ingredients_with_count">
<item formatted="false" quantity="one">%1$d ingrédient</item>
<item formatted="false" quantity="other">%1$d ingrédients</item>
</plurals>

<!-- Delete a piece of content -->
<string name="delete_confirm">Supprimer</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- The singular and plural form for Recipe Cook Time in hours -->
<plurals name="plural_recipe_cook_hours">
<item formatted="false" quantity="other">所要時間:%1$,d 時間</item>
</plurals>

<!-- People, as a filter -->
<string name="people">ユーザー</string>

<plurals name="plural_collaborators_other">
<item formatted="false" quantity="other">ボード参加者:%1$,d 人</item>
</plurals>

<!-- Header for the recipe ingredients with the ingredients countsection -->
<plurals name="pin_recipe_ingredients_with_count">
<item formatted="false" quantity="other">%1$d 個の材料</item>
</plurals>

<!-- Delete a piece of content -->
<string name="delete_confirm">削除</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- The singular and plural form for Recipe Cook Time in hours -->
<plurals name="plural_recipe_cook_hours">
<item formatted="false" quantity="one">Приготовление: %1$,d час</item>
<item formatted="false" quantity="few">Приготовление: %1$,d часа</item>
<item formatted="false" quantity="many">Приготовление: %1$,d часов</item>
<item formatted="false" quantity="other">Приготовление: %1$,d часа</item>
</plurals>

<!-- People, as a filter -->
<string name="people">Люди</string>

<plurals name="plural_collaborators_other">
<item formatted="false" quantity="one">%1$,d соавтор</item>
<item formatted="false" quantity="few">%1$,d соавтора</item>
<item formatted="false" quantity="many">%1$,d соавторов</item>
<item formatted="false" quantity="other">%1$,d соавтора</item>
</plurals>

<!-- Header for the recipe ingredients with the ingredients countsection -->
<plurals name="pin_recipe_ingredients_with_count">
<item formatted="false" quantity="one">%1$d ингредиент</item>
<item formatted="false" quantity="few">%1$d ингредиента</item>
<item formatted="false" quantity="many">%1$d ингредиентов</item>
<item formatted="false" quantity="other">%1$d ингредиента</item>
</plurals>

<!-- Delete a piece of content -->
<string name="delete_confirm">Удалить</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- The singular and plural form for Recipe Cook Time in hours -->
<plurals name="plural_recipe_cook_hours">
<item formatted="false" quantity="one">%,d hr to cook</item>
<item formatted="false" quantity="other">%,d hrs to cook</item>
</plurals>

<!-- People, as a filter -->
<string name="people">People</string>

<plurals name="plural_collaborators_other">
<item formatted="false" quantity="one">%1$,d collaborator</item>
<item formatted="false" quantity="other">%1$,d collaborators</item>
</plurals>

<!-- Header for the recipe ingredients with the ingredients countsection -->
<plurals name="pin_recipe_ingredients_with_count">
<item formatted="false" quantity="one">%d ingredient</item>
<item formatted="false" quantity="other">%d ingredients</item>
</plurals>

<!-- Delete a piece of content -->
<string name="delete_confirm">Delete</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- The singular and plural form for Recipe Cook Time in hours -->
<plurals name="plural_recipe_cook_hours">
<item formatted="false" quantity="one">%1$,d heure à cuisiner</item>
<item formatted="false" quantity="other">%1$,d heures à cuisiner</item>
</plurals>

<!-- People, as a filter -->
<string name="people">Membres</string>

<plurals name="plural_collaborators_other">
<item formatted="false" quantity="one">%1$,d collaborateur</item>
<item formatted="false" quantity="other">%1$,d collaborateurs</item>
</plurals>

<!-- Header for the recipe ingredients with the ingredients countsection -->
<plurals name="pin_recipe_ingredients_with_count">
<item formatted="false" quantity="one">%1$d ingrédient</item>
<item formatted="false" quantity="other">%1$d ingrédients </item>
</plurals>

<!-- Delete a piece of content -->
<string name="delete_confirm">Supprimer</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- The singular and plural form for Recipe Cook Time in hours -->
<plurals name="plural_recipe_cook_hours">
<item formatted="false" quantity="other">所要時間:%1$,d 時間</item>
</plurals>

<!-- People, as a filter -->
<string name="people">ユーザー</string>

<plurals name="plural_collaborators_other">
<item formatted="false" quantity="other">ボード参加者:%1$,d 人</item>
</plurals>

<!-- Header for the recipe ingredients with the ingredients countsection -->
<plurals name="pin_recipe_ingredients_with_count">
<item formatted="false" quantity="other">%1$d 個の材料</item>
</plurals>

<!-- Delete a piece of content -->
<string name="delete_confirm">削除</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<!-- The singular and plural form for Recipe Cook Time in hours -->
<plurals name="plural_recipe_cook_hours">
<item formatted="false" quantity="one">Приготовление: %1$,d час</item>
<item formatted="false" quantity="few">Приготовление: %1$,d часа</item>
<item formatted="false" quantity="many">Приготовление: %1$,d часов</item>
<item formatted="false" quantity="other">Приготовление: %1$,d часа</item>
</plurals>

<!-- People, as a filter -->
<string name="people">Люди</string>

<plurals name="plural_collaborators_other">
<item formatted="false" quantity="one">%1$,d соавтор</item>
<item formatted="false" quantity="few">%1$,d соавтора</item>
<item formatted="false" quantity="many">%1$,d соавторов</item>
<item formatted="false" quantity="other">%1$,d соавтора</item>
</plurals>

<!-- Header for the recipe ingredients with the ingredients countsection -->
<plurals name="pin_recipe_ingredients_with_count">
<item formatted="false" quantity="one">%1$d ингредиент</item>
<item formatted="false" quantity="few">%1$d ингредиента</item>
<item formatted="false" quantity="many">%1$d ингредиентов</item>
<item formatted="false" quantity="other">%1$d ингредиента</item>
</plurals>

<!-- Delete a piece of content -->
<string name="delete_confirm">Удалить</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public Map<String, String> getLocaleMapping(String localeMapppingParam) {
* Gets the inverse locale mapping given the locale mapping param
*
* @param localeMapppingParam locale mapping param coming from the CLI
* @return A map containing the inverse locale mapping (key: the tag in the repository, value: file output tag)
* @return A map containing the inverse locale mapping (key: the tag in the repository, value:
* file output tag)
*/
public Map<String, String> getInverseLocaleMapping(String localeMapppingParam) {

Expand Down
Loading

0 comments on commit 3994937

Please sign in to comment.