Skip to content

🌍 Xenoglot seamlessly masters languages and locales, empowering developers to integrate multilingual capabilities into their applications with ease.

License

Notifications You must be signed in to change notification settings

teogor/xenoglot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Xenoglot 🌍

Overview

License Maven Central Profile Open-Source Directory

Xenoglot: A Comprehensive Language Data Management Toolkit

Xenoglot is a comprehensive library for representing, managing, and interacting with language data. It provides a rich set of classes and interfaces for representing languages, dialects, scripts, language families, and regions. The library also includes methods for obtaining language tags, checking language usage patterns, and territorializing languages. Xenoglot is essential for any project that requires accurate and consistent handling of language data.

Key Features

  • Comprehensive Language Representation: Xenoglot provides a structured representation of languages, dialects, scripts, language families, and regions, enabling accurate and consistent handling of language data.

  • Language Tag Generation: Xenoglot provides methods for generating language tags, facilitating interoperability with language-related protocols and standards.

  • Language Usage Analysis: Xenoglot includes methods for checking language usage patterns, enabling informed decisions about language selection and content localization.

  • Language Territorialization: Xenoglot provides functionality for territorializing languages, adapting them to specific geographical or political contexts.

Kotlin Multiplatform Support

Xenoglot is designed to work across various platforms through Kotlin Multiplatform, allowing you to use it in JVM, Android, JavaScript, iOS, macOS, Linux, tvOS, and watchOS environments. Here are some of the supported targets:

  • JVM: Supports Java Virtual Machine with Kotlin configured for JDK 11.
  • Android: Configured to publish all library variants.
  • JavaScript: Supports WebAssembly (WASM) and JavaScript IR, including browser and Node.js environments, and generates TypeScript definitions.
  • iOS: Supports iOS devices and simulators, including iosX64, iosArm64, and iosSimulatorArm64.
  • macOS: Supports macOS with macosX64 and macosArm64.
  • Linux: Supports Linux with linuxX64 and linuxArm64.
  • tvOS: Supports tvOS devices and simulators, including tvosX64, tvosArm64, and tvosSimulatorArm64.
  • watchOS: Supports watchOS devices and simulators, including watchosX64, watchosArm32, watchosArm64, watchosDeviceArm64, and watchosSimulatorArm64.

Getting Started with Xenoglot

Adding Dependencies:

  • Manual Setup: This section guides you through adding Xenoglot dependencies directly to your project's build.gradle files. (Link to Manual Dependency Setup Section)
  • Version Catalog (Recommended): For a more streamlined approach, consider integrating a version catalog. This allows for centralized version management and easier updates. (Link to Version Catalog Section)

Note: If you prefer manual dependency setup, follow the instructions in the "Manual Setup" section. Otherwise, jump to the "Version Catalog" section for centralized management.

For information on using the KAPT plugin, see the KAPT documentation. For information on using the KSP plugin, see the KSP quick-start documentation. For more information about dependencies, see Add Build Dependencies.

Adding Xenoglot Dependencies Manually

To use Xenoglot in your app, add the following dependencies to your app's build.gradle file:

=== "Groovy"

```groovy title="build.gradle"
dependencies {
    def teogorXenoglot = "1.0.0-alpha02"

    implementation "dev.teogor.xenoglot:xenoglot-atlas:$teogorXenoglot"
    implementation "dev.teogor.xenoglot:xenoglot-atlas-extended:$teogorXenoglot"
    implementation "dev.teogor.xenoglot:xenoglot-core:$teogorXenoglot"
    implementation "dev.teogor.xenoglot:xenoglot-locale:$teogorXenoglot"
    implementation "dev.teogor.xenoglot:xenoglot-pluralization:$teogorXenoglot"
}
```

=== "Kotlin"

```kotlin title="build.gradle.kts"
dependencies {
    val teogorXenoglot = "1.0.0-alpha02"

    implementation("dev.teogor.xenoglot:xenoglot-atlas:$teogorXenoglot")
    implementation("dev.teogor.xenoglot:xenoglot-atlas-extended:$teogorXenoglot")
    implementation("dev.teogor.xenoglot:xenoglot-core:$teogorXenoglot")
    implementation("dev.teogor.xenoglot:xenoglot-locale:$teogorXenoglot")
    implementation("dev.teogor.xenoglot:xenoglot-pluralization:$teogorXenoglot")
}
```

Managing Xenoglot Versions with Version Catalog (Recommended)

This section guides you through utilizing a version catalog for centralized management of Xenoglot dependencies in your project. This approach simplifies updates and ensures consistency.

First, define the dependencies in the libs.versions.toml file:

  • Group-Name Based: This approach is used for declaring libraries referenced by group and artifact name.
  • Module Based: This approach is used for declaring libraries referenced by their module.

=== "Group-Name Based"

```toml title="gradle/libs.versions.toml"
[versions]
teogor-xenoglot = "1.0.0-alpha02"

[libraries]
teogor-xenoglot-atlas = { group = "dev.teogor.xenoglot", name = "xenoglot-atlas", version.ref = "teogor-xenoglot" }
teogor-xenoglot-atlas-extended = { group = "dev.teogor.xenoglot", name = "xenoglot-atlas-extended", version.ref = "teogor-xenoglot" }
teogor-xenoglot-core = { group = "dev.teogor.xenoglot", name = "xenoglot-core", version.ref = "teogor-xenoglot" }
teogor-xenoglot-locale = { group = "dev.teogor.xenoglot", name = "xenoglot-locale", version.ref = "teogor-xenoglot" }
teogor-xenoglot-pluralization = { group = "dev.teogor.xenoglot", name = "xenoglot-pluralization", version.ref = "teogor-xenoglot" }
```

=== "Module Based"

```toml title="gradle/libs.versions.toml"
[versions]
teogor-xenoglot = "1.0.0-alpha02"

[libraries]
teogor-xenoglot-atlas = { module = "dev.teogor.xenoglot:xenoglot-atlas", version.ref = "teogor-xenoglot" }
teogor-xenoglot-atlas-extended = { module = "dev.teogor.xenoglot:xenoglot-atlas-extended", version.ref = "teogor-xenoglot" }
teogor-xenoglot-core = { module = "dev.teogor.xenoglot:xenoglot-core", version.ref = "teogor-xenoglot" }
teogor-xenoglot-locale = { module = "dev.teogor.xenoglot:xenoglot-locale", version.ref = "teogor-xenoglot" }
teogor-xenoglot-pluralization = { module = "dev.teogor.xenoglot:xenoglot-pluralization", version.ref = "teogor-xenoglot" }
```

Then, add these dependencies in your app's build.gradle file:

=== "Groovy"

```groovy title="build.gradle"
dependencies {
    implementation libs.teogor.xenoglot.atlas
    implementation libs.teogor.xenoglot.atlas.extended
    implementation libs.teogor.xenoglot.core
    implementation libs.teogor.xenoglot.locale
    implementation libs.teogor.xenoglot.pluralization
}
```

=== "Kotlin"

```kotlin title="build.gradle.kts"
dependencies {
    implementation(libs.teogor.xenoglot.atlas)
    implementation(libs.teogor.xenoglot.atlas.extended)
    implementation(libs.teogor.xenoglot.core)
    implementation(libs.teogor.xenoglot.locale)
    implementation(libs.teogor.xenoglot.pluralization)
}
```

Usage

The following examples demonstrate how to use Xenoglot to represent and interact with language data:

Retrieving Language Information

val language = Language.English
val languageTag = language.languageTag
val languageFamily = language.languageFamily
val isSpokenInRomania = language.isSpokenIn(Country.Romania)

Checking Language Usage Patterns

val isDialect = Dialect("en-US", Language.English).isDialect
val isScriptUsedInLanguage = Script.Cyrillic.isWrittenIn(Language.Russian)

Territorializing Languages

val dialect = Language.English.territorialize(Country.Australia)
val dialectLanguageTag = dialect.languageTag
val dialectCountryCode = dialect.country.code

Benefits of Using Xenoglot

  • Improved Language Handling: Xenoglot provides a consistent and structured approach to managing language data, reducing errors and inconsistencies.

  • Enhanced Interoperability: Xenoglot facilitates interoperability with language-related protocols and standards, enabling seamless integration with external systems.

  • Simplified Language-Related Tasks: Xenoglot streamlines language-related tasks, such as localization, translation, and language detection.

  • Promote Language-Aware Development: Xenoglot encourages language-aware development practices, ensuring that language data is handled accurately and appropriately.

Pluralization Support

The xenoglot-pluralization module offers comprehensive support for pluralization, allowing you to manage and format strings based on quantities. This feature helps in correctly displaying text for different numbers of items, adapting to various pluralization rules.

Quick Start

To get started with pluralization:

  1. Create Plural Forms: Define templates for different plural categories (e.g., zero, one, few, many).
  2. Retrieve Formatted Strings: Use methods to get the appropriate string for specific quantities.

Here's a brief example:

val pluralForms = createPluralForms(
    zeroTemplate = "No items",
    oneTemplate = "One item",
    twoTemplate = "Two items",
    fewTemplate = "%d items",
    manyTemplate = "%d items",
    otherTemplate = "%d items",
)

println(pluralForms.getQuantityString(5))  // Output: "5 items"

For a more detailed guide on how to use pluralization effectively, please refer to the Pluralization Module Documentation.

Find this repository useful? 🩷

  • Support it by joining stargazers for this repository. πŸ“
  • Get notified about my new projects by following me on GitHub. πŸ’»
  • Interested in sponsoring me? Support me on GitHub! 🀝

License

  Designed and developed by 2023 teogor (Teodor Grigor)

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

About

🌍 Xenoglot seamlessly masters languages and locales, empowering developers to integrate multilingual capabilities into their applications with ease.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Languages