{"id":13529399,"url":"https://github.com/daikon-games/polyglot","last_synced_at":"2026-02-23T06:04:24.638Z","repository":{"id":45742264,"uuid":"435223014","full_name":"daikon-games/polyglot","owner":"daikon-games","description":"Polyglot is a library for GameMaker Studio for super simple loading of localized strings","archived":false,"fork":false,"pushed_at":"2024-02-03T16:12:12.000Z","size":11902,"stargazers_count":22,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-02T16:34:48.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Game Maker Language","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daikon-games.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"daikon-games","patreon":"nickavv"}},"created_at":"2021-12-05T16:43:39.000Z","updated_at":"2024-10-18T01:22:01.000Z","dependencies_parsed_at":"2024-01-03T04:07:51.229Z","dependency_job_id":"30c46055-ffe2-4932-a2d0-a63cb9628b7d","html_url":"https://github.com/daikon-games/polyglot","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daikon-games%2Fpolyglot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daikon-games%2Fpolyglot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daikon-games%2Fpolyglot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daikon-games%2Fpolyglot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daikon-games","download_url":"https://codeload.github.com/daikon-games/polyglot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246670543,"owners_count":20815002,"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-08-01T07:00:35.945Z","updated_at":"2026-02-23T06:04:24.611Z","avatar_url":"https://github.com/daikon-games.png","language":"Game Maker Language","funding_links":["https://github.com/sponsors/daikon-games","https://patreon.com/nickavv"],"categories":["Localization"],"sub_categories":["Recommendations"],"readme":"# polyglot\n![banner graphic](banner.png)\n\nPolyglot is a library for modern GameMaker Studio projects for loading localized strings easily and efficiently.\n\n#### Table of Contents\n* [Setup](#setup)\n* [Usage](#usage)\n    * [str](#str)\n        * [Interpolation and Pluralization](#interpolation-and-pluralization)\n        * [Nesting](#nesting)\n    * [setLocale](#setlocale)\n    * [getLocale](#getlocale)\n* [Licensing](#licensing)\n* [Attribution](#attribution)\n\n## Setup\n\nIntegrating Polyglot into your project is simple: just [download the latest release](https://github.com/daikon-games/polyglot/releases), and then in GameMaker Studio click on the **Tools** menu and select **Import Local Package**. Choose the `.yymps` file you downloaded, and import all assets.\n\nAlternatively you can install polyglot from the [Game Maker Marketplace](https://marketplace.yoyogames.com/assets/10472/polyglot).\n\nIf your game will use a locale named `en` (used for English language by default) then absolutely no configuration is required! If not, you will just need to call `set_locale(locale)` in your project's initialization code.\n\nYou will need to create `.json` files in a directory called `i18n` in your game's \"Included Files\" directory. Each `.json` file will contain all of the strings for a given locale.\n\nFor instance, create `your-project/datafiles/i18n/en.json` to store all of your strings for the English locale.\n\n## Usage\n\nPolyglot exposes the following functions for you to use:\n\n```\nstr(stringKey, [data])\nset_locale(locale)\ncurrent_locale()\n```\n\nLet's quickly discuss each:\n\n### str\n\nThis method will return the localized value of a string from the current locale. Since your locale file is in json format, it can contain a nested structure for easier organization.\n\nLet's say we wanted to store a string called \"hello\" under a section called \"dialog\", with the value \"Hello there!\". The `.json` contents would look like this:\n```\n{\n    \"dialog\": {\n        \"hello\": \"Hello there!\"\n    }\n}\n```\nThen to get this localized string in our game we can invoke Polyglot like so:\n```\nvar localStr = str(\"dialog.hello\");\n```\n\nSimply use `str` any time you would previously have hard-coded a string.\n\n#### Interpolation and Pluralization\n\n`str` has a few more tricks up its sleeve. Firstly, it can replace specific markers in your localization string with variable data. This can be really useful for lots of reasons, for this example let's say that we have a variable in our game called `pName` that contain's the player's name (and let's say that is set to \"Nick\" as an example), and that our dialog string looks like this.\n\n```\n{\n    \"dialog\": {\n        \"hello\": \"Hello there {name}, how are you?\"\n    }\n}\n```\nIf we call `str` with the optional second parameter, like so:\n```\nstr(\"dialog.hello\", {name: pName})\n```\nThen it will return\n```\nHello there Nick, how are you?\n```\nI'm sure you can see how powerful this could be. Additionally, we can use this feature to specify multiple pluralizations of a string that involves a numeric aspect.\n\nIn a simple case, let's imagine a simple point counter. We want the word `point` to be singular when there is 1 point, but plural (`points`) otherwise. In our language file we could define the strings like this:\n\n```\n{\n    \"score__one\": \"{count} point\",\n    \"score__plural\": \"{count} points\"\n}\n```\nThen we can call `str`\n```\nstr(\"score\", {count: currScore})\n```\nNote that we only include `score` as the string key. polyglot will automatically pick the key with `__one` or `__plural` (that's two underscores) based on the value of `count` in the data struct. To invoke this automatic pluralization the data struct must always contain a field called `count`, even if the localized strings don't use it. You can also specify a `__zero` version of your string if you want special wording for when there are none of something. Here is an example that includes a zero:\n```\n{\n    \"failures__zero\": \"Perfect run so far!\",\n    \"failures__one\": \"One little mistake...\",\n    \"failures__plural\": \"You have failed {count} times\"\n}\n```\n\n#### Nesting\n\nOne more useful feature of polyglot is the ability to nest string lookups. Take a look at this example language file:\n\n```\n{\n    \"characterNames\": {\n        \"oldMan\": \"Old Man\"\n    },\n    \"dialog\": {\n        \"greet-elder\": \"Hey there str(characterNames.oldMan)!\"\n    }\n}\n```\n\nYou may already be able to see where this is going. If we call `str`:\n\n```\nstr(\"dialog.greet-elder\")\n```\n\nThe string that is returned is\n\n```\nHey there Old Man!\n```\n\nThis can be useful for a number of reasons, but primarily if we were to change the value of `characterNames.oldMan`, every single string that references it would be updated as well. The nested string keys in the language file have to follow the specific form `str(nestedKeyPath)` where `nestedKeyPath` is a dotted json lookup path such as `characterNames.oldMan` as you see in the example above.\n\nA note, the interpolation data is passed down to the nested string lookups, so if your nested string also has variable data markers, they will be replaced using the same values as the overall string.\n\n### set_locale\n\nThis method's purpose is to change the current locale. Polyglot doesn't have any hard requirements for the names of the locales,\njust that they must be strings, and that the `.json` files you create must have the exact names of the locale you set Polyglot to use.\n\nTo change the locale, simple call `set_locale` like so:\n```\nset_locale(\"es\");\n```\n\n### current_locale\n\npolyglot also includes a method for fetching the currently set locale.\n```\ncurrent_locale()\n```\nWhich would return the string `en`, or `es`, or whatever the locale is currently set to.\n\n## Licensing\n\nPolyglot is licensed under Creative Commons BY 4.0. Essentially, you may use it, change it, ship it, and share it, with attribution.\nJust make sure to somewhere mention the use of **Polyglot by Daikon Games**!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaikon-games%2Fpolyglot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaikon-games%2Fpolyglot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaikon-games%2Fpolyglot/lists"}