{"id":19952571,"url":"https://github.com/dosmike/langswitch","last_synced_at":"2026-06-05T13:32:09.882Z","repository":{"id":133520059,"uuid":"100048882","full_name":"DosMike/LangSwitch","owner":"DosMike","description":"A localization service for sponge plugins","archived":false,"fork":false,"pushed_at":"2019-12-07T14:17:44.000Z","size":372,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-12T06:26:25.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/DosMike.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":"2017-08-11T16:02:56.000Z","updated_at":"2019-12-07T14:12:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"64dd8c7f-825a-4857-9158-121bc52f5aa1","html_url":"https://github.com/DosMike/LangSwitch","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DosMike%2FLangSwitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DosMike%2FLangSwitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DosMike%2FLangSwitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DosMike%2FLangSwitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DosMike","download_url":"https://codeload.github.com/DosMike/LangSwitch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241381645,"owners_count":19953751,"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-11-13T01:13:39.531Z","updated_at":"2026-06-05T13:32:09.827Z","avatar_url":"https://github.com/DosMike.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LangSwitch\n\nThis plugin provides a simple localiyation service for SpongePowered plugins.\n\nThe default implemetation requires a plugin to have translation files in their \nconfiguration Folder under `\u003cSERVER\u003e\\config\\\u003cPLUGIN\u003e\\Lang\\\u003cLOCALE\u003e.lang` where\n`LOCALE`is a language_COUNTRY tage like `en_US`, `fr_FR` or `de_DE`.\n\nThese language files are NO hocon configs!\nLines that start with `#` are comments, every other line should follow the\nstructure `Translation Path:Translation Text`.\n\nA translation path may only consist of lowercase letters, number and\nunderscores. The dot is used to group translations together (similar to the\npermission node system). The colon is neccessary, afterwards any text can\nfollow, representing the localised String for this translation path.\n\nPlugin developers can load LangSwitch like any service. The API package was\nnamed separately to make other implementaitons easier (They just need to copy\npaste the API package into their implementation to provide some code behind\nthe interfaces).\n\nAs 'normal' plugin developer you can proceed similar to receiving the economy\nservice:\n```\nprivate LanguageService languageService = null;\n@Listener\npublic void onChangeServiceProvider(ChangeServiceProviderEvent event) {\n  if (event.getService().equals(LanguageService.class)) {\n    languageService = (LanguageService) event.getNewProvider();\n    languageService.registerTranslation(this); //add this plugin to the translation provider\n  }\n}\npublic static LanguageService getTranslator() { return instance.languageService; }\n```\nThe line languageService.registerTranslation(this); is important so the provider\nwill be able to inject the translations into your PluginTranslation object.\nYou can receive a PluginTranslation object either from \n`languageService.registerTranslation(this)` or at any point using\n`languageService().getTranslation(this)`. The later method returns a optional \nthat will be empty if registerTranslation was not yet called.\n\n**Don't forget that your plugin now depends on LangSwitch so you'll have to add the dependency in your mcmod.info like**\n`\"dependencies\": [ \"langswitch\" ]`\n\nFrom the PluginTranslation you normally proceed like\n```\nLocalized\u003cString\u003e localized = translation.local(\"cmd.success\");\nlocalized.replace(\"%name%\", displayName);\nplayer.sendMessage(Text.of(localized.resolve(player).orElse(\"[command success message]\")));\n```\nthe replace method returns the localized so you can chain the block into a \nsingle line if wanted. Resovle returns a optional, that will be empty if no\ntranslation could be received.\n\nThere is also `translation.localText` that is capable of handling Text\nplaceholders incase you plan on having clickable chat messages. The above\nexample would change to something like this:\n```\nLocalized\u003cText\u003e localized = translation.localText(\"cmd.success\");\nlocalized.replace(\"%name%\", Text.of(TextColors.GREEN, displayName));\nplayer.sendMessage(localized.resolve(player).orElse(Text.of(\"[command success message]\")));\n```\n\nLangSwitch will use the server default locale as fallback language for all\nplugins. If this is not desired you can change the default language in the\nconfig under `SERVER\\config\\langswitch.conf`. Just set the value for\n`DefaultLocale` to a locale as described at the top of this readme.\n\nExample config:\n```\n# This is the default fallback language for the server.\n# If a translation is missing this language will be used,\n# so make sure that the translations for this language are complete.\nDefaultLocale=en_US\n\n# Verbose logging will inform you about any missing or\n# broken translations. It is recommended that you boot\n# up with this enabled at least once after updates,\n# to get a quick glimpse if everything is ok.\nVerboseLogging=true\n\n# It's strongly recommended to enable automatic version checking,\n# This will also inform you about changes in dependencies.\n# Set this value to true to allow this Plugin to check for Updates on Ore\nVersionChecker=false\n```\n\n### Depending on this plugin\n\nThis plugin is jitpack-compatible, if you're using gradle just add this:\n```{groovy}\nrepositories {\n    ...\n    maven { url \"https://jitpack.io\" }\n}\ndependencies {\n    ...\n    compile 'com.github.DosMike:LangSwitch:master-SNAPSHOT'\n}\n```\n\n### External Connections\n\n**[Version Checker](https://github.com/DosMike/SpongePluginVersionChecker)**  \nThis plugin uses a version checker to notify you about available updates.  \nThis updater is **disabled by default** and can be enabled in `config/langswitch.conf`\nby setting the value `VersionChecker` to `true`.  \nIf enabled it will asynchronously check (once per server start) if the Ore repository has any updates.  \nThis will *only print update notes into the server log*, no files are being downlaoded!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdosmike%2Flangswitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdosmike%2Flangswitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdosmike%2Flangswitch/lists"}