Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Kotlin 2.0.0 #67

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions buildSrc/src/main/kotlin/i18n4k.kmp-build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("multiplatform")
}
Expand All @@ -6,8 +8,8 @@ plugins {

kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
testRuns["test"].executionTask.configure {
useJUnit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package de.comahe.i18n4k.cldr.plurals

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.country
import de.comahe.i18n4k.createLocale
import de.comahe.i18n4k.language
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.cldr.plurals.PluralRule
import de.comahe.i18n4k.cldr.plurals.PluralRuleType

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.cldr.plurals.PluralCategory
import de.comahe.i18n4k.cldr.plurals.PluralRule
import de.comahe.i18n4k.messages.formatter.parsing.StylePart
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.cldr.plurals.PluralRule
import de.comahe.i18n4k.cldr.plurals.PluralRuleType

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.comahe.i18n4k.messages.formatter

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.config.I18n4kConfigDefault
import de.comahe.i18n4k.createLocale
import de.comahe.i18n4k.i18n4k
import de.comahe.i18n4k.i18n4kInitCldrPluralRules
import kotlin.test.BeforeTest
Expand All @@ -19,7 +19,7 @@ class MessagePluralsTest {
fun init() {
i18n4k = i18n4kConfig
i18n4kConfig.restoreDefaultSettings()
i18n4kConfig.locale = Locale("en")
i18n4kConfig.locale = createLocale("en")

MessagesPlurals.unregisterAllTranslations()
MessagesPlurals.registerTranslation(MessagesPlurals_en)
Expand All @@ -30,7 +30,7 @@ class MessagePluralsTest {

@Test
fun cardinalTest_en() {
i18n4kConfig.locale = Locale("en")
i18n4kConfig.locale = createLocale("en")

assertEquals("1 month", MessagesPlurals.MONTH_COUNT("1"))
assertEquals("1 month", MessagesPlurals.MONTH_COUNT(1))
Expand All @@ -50,7 +50,7 @@ class MessagePluralsTest {

@Test
fun cardinalTest_de() {
i18n4kConfig.locale = Locale("de")
i18n4kConfig.locale = createLocale("de")

assertEquals("1 Monat", MessagesPlurals.MONTH_COUNT("1"))
assertEquals("1 Monat", MessagesPlurals.MONTH_COUNT(1))
Expand All @@ -70,7 +70,7 @@ class MessagePluralsTest {

@Test
fun cardinalTest_pl() {
i18n4kConfig.locale = Locale("pl")
i18n4kConfig.locale = createLocale("pl")

assertEquals("1 miesiąc", MessagesPlurals.MONTH_COUNT("1"))
assertEquals("1 miesiąc", MessagesPlurals.MONTH_COUNT(1))
Expand All @@ -90,7 +90,7 @@ class MessagePluralsTest {

@Test
fun ordinalTest_en() {
i18n4kConfig.locale = Locale("en")
i18n4kConfig.locale = createLocale("en")

assertEquals("1st rank", MessagesPlurals.RANK_ORDINAL("1"))
assertEquals("1st rank", MessagesPlurals.RANK_ORDINAL(1))
Expand All @@ -111,7 +111,7 @@ class MessagePluralsTest {

@Test
fun ordinalTest_de() {
i18n4kConfig.locale = Locale("de")
i18n4kConfig.locale = createLocale("de")

assertEquals("1. Rang", MessagesPlurals.RANK_ORDINAL("1"))
assertEquals("1. Rang", MessagesPlurals.RANK_ORDINAL(1))
Expand All @@ -132,7 +132,7 @@ class MessagePluralsTest {

@Test
fun ordinalTest_pl() {
i18n4kConfig.locale = Locale("pl")
i18n4kConfig.locale = createLocale("pl")

assertEquals("1. rząd", MessagesPlurals.RANK_ORDINAL("1"))
assertEquals("1. rząd", MessagesPlurals.RANK_ORDINAL(1))
Expand Down
10 changes: 9 additions & 1 deletion i18n4k-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@file:OptIn(ExperimentalKotlinGradlePluginApi::class)

import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
id("i18n4k.kmp-build")
id("i18n4k.publish-build")
Expand All @@ -6,7 +10,7 @@ plugins {

kotlin {
// the sources of all the targets
@Suppress("UNUSED_VARIABLE", "UnusedPrivateMember")
@Suppress("UnusedPrivateMember")
sourceSets {

val commonMain by getting {
Expand Down Expand Up @@ -43,4 +47,8 @@ kotlin {
}
}
}

compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fun createDefaultLocaleImpl(

return DefaultLocaleImpl(
language.trim().lowercase(),
script?.trim()?.capitalize() ?: "",
script?.trim()?.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() } ?: "",
country?.trim()?.uppercase() ?: "",
variant?.trim()?.lowercase() ?: "",
extensionsBuilder.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ val Locale.lessSpecificLocale: Locale
var result = lessSpecificLocaleCache.value[this]
if (result === null) {
result = if (variant.isEmpty())
Locale(language)
createLocale(language)
else
Locale(language, country)
createLocale(language, country)
}
lessSpecificLocaleCache.update { it.put(this, result) }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.config

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatter
import de.comahe.i18n4k.messages.formatter.provider.DeclensionProvider
import de.comahe.i18n4k.messages.formatter.provider.DeclensionProviderDefault
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.comahe.i18n4k.config

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.createLocale
import de.comahe.i18n4k.messages.formatter.MessageFormatter
import de.comahe.i18n4k.messages.formatter.MessageFormatterDefault
import de.comahe.i18n4k.messages.formatter.provider.DeclensionProvider
Expand All @@ -22,7 +22,7 @@ class I18n4kConfigDefault : I18n4kConfig {

/** atomic ref for [defaultLocale] */
private val defaultLocaleRef: AtomicRef<Locale> =
atomic(Locale("en"))
atomic(createLocale("en"))

/** atomic ref for [locale] */
private val localeRef: AtomicRef<Locale> =
Expand All @@ -47,7 +47,7 @@ class I18n4kConfigDefault : I18n4kConfig {

/** Restores the default settings. */
fun restoreDefaultSettings() {
defaultLocale = Locale("en")
defaultLocale = createLocale("en")
locale = systemLocale
messageFormatter = MessageFormatterDefault
treadBlankStringAsNull = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.config

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatter
import de.comahe.i18n4k.messages.formatter.provider.DeclensionProvider
import de.comahe.i18n4k.messages.formatter.provider.GenderProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.config

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatter
import de.comahe.i18n4k.messages.formatter.provider.DeclensionProvider
import de.comahe.i18n4k.messages.formatter.provider.GenderProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package de.comahe.i18n4k.config

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.createLocale
import de.comahe.i18n4k.forLocaleTag
import de.comahe.i18n4k.messages.formatter.MessageFormatter
import de.comahe.i18n4k.messages.formatter.MessageFormatterDefault
Expand Down Expand Up @@ -28,7 +28,7 @@ data class I18n4kConfigImmutable(
) : I18n4kConfig {
/** constructor for getting the default settings */
constructor() : this(
defaultLocale = Locale("en"),
defaultLocale = createLocale("en"),
locale = systemLocale,
messageFormatter = MessageFormatterDefault,
treadBlankStringAsNull = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package de.comahe.i18n4k.messages

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.applyLocales
import de.comahe.i18n4k.i18n4k
import de.comahe.i18n4k.lessSpecificLocale
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.NameToIndexMapperNumbersFrom0

/** The formatter used to insert and format the parameters of the message text */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.parsing.MessageParser
import de.comahe.i18n4k.messages.formatter.parsing.MessagePart
import de.comahe.i18n4k.messages.formatter.types.MessageAttribSelectFormatter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.parsing.StylePart

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.parsing

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.parsing

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
import kotlinx.collections.immutable.ImmutableList
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.parsing

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
import de.comahe.i18n4k.strings.toString
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.parsing

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.provider

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.strings.LocalizedAttributable
import de.comahe.i18n4k.strings.LocalizedString

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.provider

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.strings.LocalizedAttributable
import de.comahe.i18n4k.strings.LocalizedString

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.types

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
import de.comahe.i18n4k.messages.formatter.MessageValueFormatter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.types

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
import de.comahe.i18n4k.messages.formatter.MessageValueFormatter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.types

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.i18n4k
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.types

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.i18n4k
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.types

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
import de.comahe.i18n4k.messages.formatter.MessageValueFormatter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.types

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
import de.comahe.i18n4k.messages.formatter.MessageValueFormatter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.formatter.types

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.messages.formatter.MessageFormatContext
import de.comahe.i18n4k.messages.formatter.MessageParameters
import de.comahe.i18n4k.messages.formatter.MessageValueFormatter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package de.comahe.i18n4k.messages.providers

import de.comahe.i18n4k.Locale

/** Provides traslations for a message bundle for a given locale */
interface MessagesProvider {
/** which locale does the provider use*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package de.comahe.i18n4k.messages.providers

import de.comahe.i18n4k.Locale

/** A [MessagesProvider] that uses a simple list */
@Suppress("unused")
class MessagesProviderViaList(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package de.comahe.i18n4k.messages.providers

import de.comahe.i18n4k.Locale

/** Base class for loading the data of a [MessagesProvider] via a lazy loaded list of string */
@Suppress("unused")
abstract class MessagesProviderViaLoading(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.comahe.i18n4k.messages.providers

import de.comahe.i18n4k.Locale
import de.comahe.i18n4k.forLocaleTag
import de.comahe.i18n4k.language

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package de.comahe.i18n4k.messages.providers

import de.comahe.i18n4k.Locale

/** Load a text string.
*
* Text must be formatted as described in [MessagesProviderViaLoadingText] */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package de.comahe.i18n4k.strings

import de.comahe.i18n4k.Locale

/** A combination of two [LocalizedString] forming a new one */
class CompositeLocalizedString(
private val string1: LocalizedString,
Expand Down
Loading
Loading