Skip to content

Commit

Permalink
fix: snake case language template placeholder (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 authored Jul 30, 2024
1 parent c3ca3cb commit 98d1904
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ExportFilePathProvider(
)
.replacePlaceholder(
ExportFilePathPlaceholder.SNAKE_LANGUAGE_TAG,
convertBCP47ToAndroidResourceFormat(getSnakeLanguageTag(languageTag)),
getSnakeLanguageTag(languageTag),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class JsonFileExporterTest {
translations =
buildExportTranslationList {
add(
languageTag = "cs",
languageTag = "cs-CZ",
keyName = "item",
text = "A",
)
Expand All @@ -206,7 +206,53 @@ class JsonFileExporterTest {

val files = exporter.produceFiles()

files["cs/hello.json"].assert.isNotNull()
files["cs-CZ/hello.json"].assert.isNotNull()
}

@Test
fun `honors the provided fileStructureTemplate (snakeCase)`() {
val exporter =
getExporter(
translations =
buildExportTranslationList {
add(
languageTag = "cs-CZ",
keyName = "item",
text = "A",
)
}.translations,
exportParams =
ExportParams().also {
it.fileStructureTemplate = "{snakeLanguageTag}/hello/{namespace}.{extension}"
},
)

val files = exporter.produceFiles()

files["cs_CZ/hello.json"].assert.isNotNull()
}

@Test
fun `honors the provided fileStructureTemplate (androidLanguageTag)`() {
val exporter =
getExporter(
translations =
buildExportTranslationList {
add(
languageTag = "cs-CZ",
keyName = "item",
text = "A",
)
}.translations,
exportParams =
ExportParams().also {
it.fileStructureTemplate = "{androidLanguageTag}/hello/{namespace}.{extension}"
},
)

val files = exporter.produceFiles()

files["cs-rCZ/hello.json"].assert.isNotNull()
}

private fun Map<String, InputStream>.getFileTextContent(fileName: String): String {
Expand Down
2 changes: 2 additions & 0 deletions e2e/cypress/e2e/translations/batchJobs.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ function assertLanguagesSelected(languages: string[]) {
.findDcy('translations-language-select-form-control')
.click();

cy.gcy('translations-language-select-item').should('be.visible');

languages.forEach((language) => {
cy.gcy('translations-language-select-item')
.contains(language)
Expand Down

0 comments on commit 98d1904

Please sign in to comment.