-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add native support for (de-)serialization of *.po files (can be used …
…from both Java and Javascript)
- Loading branch information
Showing
12 changed files
with
299 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
image: registry.gitlab.com/josm/docker-library/openjdk-8-git:latest | ||
image: registry.gitlab.com/josm/docker-library/openjdk-11-git:latest | ||
|
||
before_script: | ||
- export GRADLE_USER_HOME=`pwd`/.gradle | ||
|
@@ -19,36 +19,9 @@ assemble: | |
paths: | ||
- build/ | ||
|
||
assemble on java11: | ||
stage: build | ||
image: registry.gitlab.com/josm/docker-library/openjdk-11-git:latest | ||
script: | ||
- ./gradlew --stacktrace jar | ||
artifacts: | ||
paths: | ||
- build/ | ||
|
||
assemble on java12: | ||
stage: build | ||
image: registry.gitlab.com/josm/docker-library/openjdk-12-git:latest | ||
script: | ||
- ./gradlew --stacktrace jar | ||
artifacts: | ||
paths: | ||
- build/ | ||
|
||
assemble on java13: | ||
stage: build | ||
image: registry.gitlab.com/josm/docker-library/openjdk-13-git:latest | ||
script: | ||
- ./gradlew --stacktrace jar | ||
artifacts: | ||
paths: | ||
- build/ | ||
|
||
test: | ||
stage: test | ||
image: registry.gitlab.com/josm/docker-library/openjdk-8-josmplugin | ||
image: registry.gitlab.com/josm/docker-library/openjdk-11-josmplugin | ||
script: | ||
- ./gradlew --stacktrace --info build :dokkaHtmlMultimodule :jacocoTestReport | ||
artifacts: | ||
|
@@ -61,38 +34,15 @@ test: | |
needs: | ||
- assemble | ||
|
||
test on java11: | ||
stage: test | ||
image: registry.gitlab.com/josm/docker-library/openjdk-11-josmplugin:latest | ||
script: | ||
- ./gradlew --stacktrace --info build | ||
needs: | ||
- assemble on java11 | ||
|
||
test on java12: | ||
stage: test | ||
image: registry.gitlab.com/josm/docker-library/openjdk-12-josmplugin:latest | ||
script: | ||
- ./gradlew --stacktrace --info build | ||
needs: | ||
- assemble on java12 | ||
|
||
test on java13: | ||
stage: test | ||
image: registry.gitlab.com/josm/docker-library/openjdk-13-josmplugin:latest | ||
script: | ||
- ./gradlew --stacktrace --info build | ||
needs: | ||
- assemble on java13 | ||
|
||
publish to / Gradle Plugin Portal: | ||
stage: deploy | ||
environment: | ||
name: maven / Gradle Plugin Portal | ||
url: https://plugins.gradle.org/plugin/org.openstreetmap.josm | ||
script: | ||
- ./gradlew -Pgradle.publish.secret="$GRADLE_PUBLISH_SECRET" -Pgradle.publish.key="$GRADLE_PUBLISH_KEY" publishPlugins | ||
needs: [ "test", "test on java11", "test on java12", "test on java13" ] | ||
needs: | ||
- test | ||
only: | ||
- tags@floscher/gradle-josm-plugin | ||
|
||
|
@@ -104,7 +54,8 @@ publish to / GitLab.com Maven: | |
script: | ||
- ./gradlew publishAllPublicationsToGitlabRepository | ||
- ./gradlew releaseToGitlab | ||
needs: [ "test", "test on java11", "test on java12", "test on java13" ] | ||
needs: | ||
- test | ||
only: | ||
- tags@floscher/gradle-josm-plugin | ||
|
||
|
@@ -138,6 +89,7 @@ publish to / pages branch: | |
git config user.email "incoming+floscher/[email protected]" | ||
git commit -a -m "Update Maven repository and KDoc documentation to $longVersion" | ||
git push origin pages | ||
needs: [ "test", "test on java11", "test on java12", "test on java13" ] | ||
needs: | ||
- test | ||
only: | ||
- tags@floscher/gradle-josm-plugin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ plugins { | |
} | ||
|
||
kotlin { | ||
explicitApiWarning() | ||
js().browser() | ||
jvm() | ||
} | ||
|
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
28 changes: 28 additions & 0 deletions
28
i18n/src/commonMain/kotlin/org/openstreetmap/josm/gradle/plugin/i18n/io/GettextUtil.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,28 @@ | ||
package org.openstreetmap.josm.gradle.plugin.i18n.io | ||
|
||
|
||
internal val GETTEXT_CONTENT_TYPE_UTF8: String = "Content-Type: text/plain; charset=UTF-8" | ||
internal val GETTEXT_EMPTY_HEADER: Pair<MsgId, MsgStr> = MsgId(MsgStr("")) to MsgStr("") | ||
internal val GETTEXT_DEFAULT_HEADER: Pair<MsgId, MsgStr> = MsgId(MsgStr("")) to MsgStr("$GETTEXT_CONTENT_TYPE_UTF8\n") | ||
|
||
/** | ||
* If the [msgid] is just the empty string, returns a modified [msgstr] that contains the UTF-8 content type. | ||
* Otherwise returns the given [msgstr] unmodified. | ||
*/ | ||
internal fun Map<MsgId, MsgStr>.ensureUtf8EncodingInHeaderEntry(): List<Pair<MsgId, MsgStr>> = | ||
mapOf(GETTEXT_EMPTY_HEADER).plus(this).map { (key, value) -> | ||
if (key == MsgId(MsgStr(""))) { | ||
key to MsgStr( | ||
value.strings.mapIndexed { index, str -> | ||
if (index == 0) { | ||
str.lines() | ||
.filter { !it.startsWith("Content-Type:") && !it.isEmpty() } | ||
.plus(GETTEXT_CONTENT_TYPE_UTF8) | ||
.joinToString("\n", "", "\n") | ||
} else { | ||
str | ||
} | ||
} | ||
) | ||
} else key to value | ||
} |
15 changes: 15 additions & 0 deletions
15
i18n/src/commonMain/kotlin/org/openstreetmap/josm/gradle/plugin/i18n/io/I18nFileFormat.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,15 @@ | ||
package org.openstreetmap.josm.gradle.plugin.i18n.io | ||
|
||
/** | ||
* Represents a file format for i18n that allows for encoding strings and their translations into a [ByteArray] | ||
* and decoding them again from such a [ByteArray]. | ||
*/ | ||
public interface I18nFileFormat { | ||
/** | ||
* Encode the [translations] given as parameter to the [I18nFileFormat] | ||
* @param translations the translations that should be encoded | ||
* @return the encoded bytes | ||
*/ | ||
public fun encodeToByteArray(translations: Map<MsgId, MsgStr>): ByteArray | ||
public fun decodeToTranslations(bytes: ByteArray): Map<MsgId, MsgStr> | ||
} |
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
Oops, something went wrong.