Skip to content

Commit

Permalink
fix: snake language template placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 committed Jul 30, 2024
1 parent 25262d7 commit 73e67be
Show file tree
Hide file tree
Showing 2 changed files with 49 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

0 comments on commit 73e67be

Please sign in to comment.