-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: structural and readability fixes + removing duplicates
- Loading branch information
Showing
12 changed files
with
85 additions
and
88 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
12 changes: 12 additions & 0 deletions
12
backend/data/src/main/kotlin/io/tolgee/formats/getGroupOrNull.kt
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,12 @@ | ||
package io.tolgee.formats | ||
|
||
fun MatchGroupCollection.getGroupOrNull(name: String): MatchGroup? { | ||
try { | ||
return this[name] | ||
} catch (e: IllegalArgumentException) { | ||
if (e.message?.contains("No group with name") != true) { | ||
throw e | ||
} | ||
return null | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
backend/data/src/main/kotlin/io/tolgee/formats/i18next/ParsedI18nextKey.kt
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
backend/data/src/main/kotlin/io/tolgee/formats/i18next/PluralsI18nextKeyParser.kt
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...gee/formats/i18next/ParsedI18nextParam.kt → .../formats/i18next/in/ParsedI18nextParam.kt
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
16 changes: 16 additions & 0 deletions
16
backend/data/src/main/kotlin/io/tolgee/formats/i18next/in/PluralsI18nextKeyParser.kt
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,16 @@ | ||
package io.tolgee.formats.i18next.`in` | ||
|
||
import io.tolgee.formats.getGroupOrNull | ||
import io.tolgee.formats.importCommon.ParsedPluralsKey | ||
import io.tolgee.formats.importCommon.PluralsKeyParser | ||
|
||
class PluralsI18nextKeyParser(private val keyRegex: Regex) : PluralsKeyParser { | ||
override fun parse(key: String): ParsedPluralsKey { | ||
val match = keyRegex.find(key) | ||
return ParsedPluralsKey( | ||
key = match?.groups?.getGroupOrNull("key")?.value, | ||
plural = match?.groups?.getGroupOrNull("plural")?.value, | ||
originalKey = key, | ||
) | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
backend/data/src/main/kotlin/io/tolgee/formats/importCommon/ParsedPluralsKey.kt
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 @@ | ||
package io.tolgee.formats.importCommon | ||
|
||
data class ParsedPluralsKey( | ||
val key: String? = null, | ||
val plural: String? = null, | ||
val originalKey: String, | ||
) |
5 changes: 5 additions & 0 deletions
5
backend/data/src/main/kotlin/io/tolgee/formats/importCommon/PluralsKeyParser.kt
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,5 @@ | ||
package io.tolgee.formats.importCommon | ||
|
||
interface PluralsKeyParser { | ||
fun parse(key: String): ParsedPluralsKey | ||
} |
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