{"id":16405661,"url":"https://github.com/aecsocket/glossa","last_synced_at":"2025-02-23T19:24:04.036Z","repository":{"id":129001392,"uuid":"601358994","full_name":"aecsocket/glossa","owner":"aecsocket","description":"Localization library for Adventure components","archived":false,"fork":false,"pushed_at":"2023-07-14T20:53:16.000Z","size":235,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-05T11:42:56.071Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aecsocket.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-13T22:34:52.000Z","updated_at":"2023-05-05T10:56:12.000Z","dependencies_parsed_at":"2024-11-12T12:36:45.629Z","dependency_job_id":null,"html_url":"https://github.com/aecsocket/glossa","commit_stats":{"total_commits":53,"total_committers":1,"mean_commits":53.0,"dds":0.0,"last_synced_commit":"df0da501657d024492d3fd14ba56301cf156db8d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fglossa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fglossa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fglossa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fglossa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aecsocket","download_url":"https://codeload.github.com/aecsocket/glossa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240366090,"owners_count":19790019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T06:06:53.435Z","updated_at":"2025-02-23T19:24:03.992Z","avatar_url":"https://github.com/aecsocket.png","language":"Kotlin","readme":"\u003cdiv align=\"center\"\u003e\n\n# Glossa\n[![CI](https://img.shields.io/github/actions/workflow/status/aecsocket/glossa/build.yml)](https://github.com/aecsocket/glossa/actions/workflows/build.yml)\n[![Release](https://img.shields.io/maven-central/v/io.github.aecsocket/glossa?label=release)](https://central.sonatype.com/artifact/io.github.aecsocket/glossa)\n[![Snapshot](https://img.shields.io/nexus/s/io.github.aecsocket/glossa?label=snapshot\u0026server=https%3A%2F%2Fs01.oss.sonatype.org)](https://central.sonatype.com/artifact/io.github.aecsocket/glossa)\n\nLocalization library for Adventure components\n\n### [GitHub](https://github.com/aecsocket/glossa) · [Docs](https://aecsocket.github.io/glossa) · [Dokka](https://aecsocket.github.io/glossa/dokka)\n\n\u003c/div\u003e\n\nGlossa provides a simple and opinionated API for developers to create localizable versions of their\nsoftware, and provides server admins and translators with tools to create translations based on\npowerful and useful features like the MiniMessage format and Unicode ICU templates. It is designed\nfor Kotlin, with minimal support for Java.\n\n## Usage\n\nSee the version badges for the latest release and snapshot builds.\n\nModules:\n- `glossa` - core API\n- `glossa-configurate` - tools for the [Configurate](https://github.com/spongepowered/configurate)\n  library\n\n```kotlin\nrepositories {\n  mavenCentral()\n  // for snapshot builds\n  // maven(\"https://s01.oss.sonatype.org/content/repositories/snapshots/\")\n}\n\ndependencies {\n  implementation(\"io.github.aecsocket\", \"glossa\", \"VERSION\")\n}\n```\n\n### Setting up Glossa\n\n#### Using the Kotlin DSL\n\n```kotlin\nval english = Locale.forLanguageTag(\"en-US\")\nval glossa = glossaStandard(\n    defaultLocale = english,\n    invalidMessageProvider = InvalidMessageProvider.Default,\n) {\n    substitutions {\n        substitution(\"icon_item\", Component.text(\"🪙\"))\n    }\n    \n    styles {\n        style(\"color_variable\", Style.style(NamedTextColor.YELLOW))\n    }\n    \n    translation(english) {\n        message(\"hello_world\", \"Hello world!\")\n\n        messageList(\"found_item\",\n            \"\u003cicon_item\u003e You found \u003citem_name\u003e!\",\n            \"\u003cicon_item\u003e You picked up \u003citem_name\u003e!\",\n            \"\u003cicon_item\u003e You obtained \u003citem_name\u003e!\",\n        )\n        \n        section(\"command\") {\n            message(\"state\", \"\"\"\n                System state:\n                  - Foo: \u003ccolor_variable\u003e\u003cfoo\u003e\n                  - Bar: \u003ccolor_variable\u003e\u003cbar\u003e\n                \"\"\".trimIndent())\n            message(\"players_online\", \"\"\"\n                There {players, plural,\n                    =0 {are no players}\n                    one {is \u003ccolor_variable\u003e#\u003c/color_variable\u003e player}\n                    other {are \u003ccolor_variable\u003e#\u003c/color_variable\u003e players}\n                } online.\n                \"\"\".trimIndent())\n        }\n    }\n}\n```\n\n#### Using Configurate\n\n```yaml\nsubstitutions:\n  icon_item: \"🪙\"\n  \nstyles:\n  color_variable:\n    color: yellow\n\ntranslations:\n  en-US:\n    hello_world: \"Hello world!\"\n    found_item:\n      - \"\u003cicon_item\u003e You found \u003citem_name\u003e!\"\n      - \"\u003cicon_item\u003e You picked up \u003citem_name\u003e!\"\n      - \"\u003cicon_item\u003e You obtained \u003citem_name\u003e!\"\n    command:\n      # `|-`: preserve newlines, remove last newline\n      state: |-\n        System state:\n          - Foo: \u003ccolor_variable\u003e\u003cfoo\u003e\n          - Bar: \u003ccolor_variable\u003e\u003cbar\u003e\n      # `\u003e-`: remove newlines, remove last newline\n      players_online: \u003e-\n        There {players, plural,\n          =0 {are no players}\n          one {is \u003ccolor_variable\u003e#\u003c/color_variable\u003e player}\n          other {are \u003ccolor_variable\u003e#\u003c/color_variable\u003e players}\n        } online.\n```\n\n```kotlin\nval glossa = glossaStandard(\n    defaultLocale = english,\n    invalidMessageProvider = InvalidMessageProvider.Default,\n) {\n    try {\n        fromConfigLoader(YamlConfigurationLoader.builder()\n            .file(myLangFile)\n            .build()\n        )\n    } catch (ex: Exception) {\n        ex.printStackTrace()\n    }\n}\n```\n\n### Generating messages\n\n#### Using method generation calls\n\n```kotlin\n// typealias Message = List\u003cComponent\u003e\n\nval message: Message = glossa.message(\"hello_world\")\n// [ \"Hello world!\" ]\n\nval foundItem: List\u003cMessage\u003e = glossa.messageList(\"found_item\") {\n    replace(\"item_name\", Component.text(\"Epic Sword\", NamedTextColor.BLUE))\n}\n// [\n//   \"🪙 You found \u003cblue\u003eEpic Sword\u003c/blue\u003e!\",\n//   \"🪙 You picked up \u003cblue\u003eEpic Sword\u003c/blue\u003e!\",\n//   \"🪙 You obtained \u003cblue\u003eEpic Sword\u003c/blue\u003e!\"\n// ]\n```\n\n#### Using a message proxy\n\n```kotlin\ninterface MyMessages {\n    // @MessageKey(\"hello_world\") // optional, explicitly specify message key\n    fun helloWorld(): Message\n    \n    fun foundItem(\n        // @Placeholder(\"item_name\") // optional, explicitly specify placeholder key\n        itemName: Component,\n    ): List\u003cMessage\u003e\n    \n    // @SectionKey(\"command\") // optional, explicitly specify subsection key\n    val command: Command\n    interface Command {\n        fun state(\n            foo: Component,\n            bar: Component,\n        ): Message\n        \n        fun playersOnline(\n            players: Int\n        ): Message\n    }\n}\n\nval messages: MessageProxy\u003cMyMessages\u003e = glossa.messageProxy\u003cMyMessages\u003e()\n\nval commandOutput: Message = messages.forLocale(english).command.state(\n    foo = Component.text(\"OK\"),\n    bar = Component.text(\"ERROR\"),\n)\n// [\n//   \"System state:\",\n//   \"- Foo: \u003cyellow\u003eOK\",\n//   \"- Bar: \u003cyellow\u003eERROR\"\n// ]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faecsocket%2Fglossa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faecsocket%2Fglossa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faecsocket%2Fglossa/lists"}