{"id":20112274,"url":"https://github.com/swiftaff/txty","last_synced_at":"2025-07-08T03:33:19.801Z","repository":{"id":57383085,"uuid":"109845390","full_name":"Swiftaff/txty","owner":"Swiftaff","description":"A basic language pack to allow you to easily change languages in your node.js app","archived":false,"fork":false,"pushed_at":"2017-11-09T17:51:11.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T04:04:27.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Swiftaff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-07T14:20:40.000Z","updated_at":"2017-11-07T15:03:32.000Z","dependencies_parsed_at":"2022-09-11T04:12:26.954Z","dependency_job_id":null,"html_url":"https://github.com/Swiftaff/txty","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftaff%2Ftxty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftaff%2Ftxty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftaff%2Ftxty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Swiftaff%2Ftxty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Swiftaff","download_url":"https://codeload.github.com/Swiftaff/txty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241556733,"owners_count":19981874,"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-13T18:19:38.417Z","updated_at":"2025-03-02T18:42:08.521Z","avatar_url":"https://github.com/Swiftaff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Txty\n\n[![Build Status](https://travis-ci.org/Swiftaff/txty.svg?branch=master)](https://travis-ci.org/Swiftaff/txty)\n[![Coverage Status](https://coveralls.io/repos/github/Swiftaff/txty/badge.svg?branch=master)](https://coveralls.io/github/Swiftaff/txty?branch=master)\n\nA basic language pack manager to make it easy to swap out all the text in your node.js app interface.\n\nIt doesn't translate anything though :-) You will need to go get all the translations you need for your dictionary files yourself. There may be better alternatives out there, but this is a simple project with no bells and whistles.\n\n* Just use it with a single language, to help keep the wording used within your interface elements consistent and easy to update in one place, e.g. `page_title: \"Welcome to txty\"` or `homepage_download_button: \"Download Free Now!\"`\n* Turn on debugging to [**highlight**] your **txty**-fied text in the front-end, so you can easily hunt down un-**txty**-fied text!\n* Add other language dictionary files so you can easily and consistently change language\n* No dependencies\n\n## Installation\n\nThis is just Javascript, but it is intended for Node.js use\n1. [Download](https://nodejs.org/en/download/) and [Install](https://docs.npmjs.com/getting-started/installing-node) Node.js\n2. Create your project any way you like, e.g. using [Express](https://www.npmjs.com/package/express)\n3. Install **txty** `npm install txty --save`\n\n## Require\nInclude **txty** at the top of any js file where you wish to **txty**-fy your plain text `var txty = require(\"txty\");`\n\nor, e.g. if you are using Express, simply include once in your main app.js, and just pass the **txty** variable around as needed using locals `req.app.locals.txty = require(\"txty\");`\n\n## init(options)\nInitialise **txty** with it's default options (see defaults below)\n`txty.init();`\n\nOr Initialise with options (see options below).\n`txty.init( { lang: \"en\" } );`\n\nRun the same command with different settings later, e.g. to change language, or alter the dictionary\n`txty.init( { lang: \"fr\" } );`\n\nThen, wherever required in your js, replace any instances of plain text...\n`var outputText = \"Download Free Now!\"`\n...with a ***txty*** call to your predefined key/value pair\n`var outputText = txty.get(\"homepage_download_button\")`\n\n## Options\n\n### dictionary\nShould contain one object for each language, e.g. English, French and Klingon. Minimum one language.\n```\ndictionary: {\n    en: {},\n    fr: {},\n    kl: {}\n}\n```\nThen within each language, simply create the same keys with the relevant values for each language, e.g.\n```\ndictionary: {\n    en: {\n        hello: \"Hello\",\n        goodbye: \"Goodbye\"\n    },\n    fr: {\n        hello: \"Bonjour\",\n        goodbye: \"Au Revoir\"\n    },\n    kl: {\n        hello: \"nuqneH\",\n        goodbye: \"DaH jImej\"\n    }\n}\n```\nor define your dictionaries in separate files, and require them\n```\ndictionary: {\n    en: require(\"./languages/en.js\"),\n    fr: require(\"./languages/fr.js\"),\n    kl: require(\"./languages/kl.js\")\n}\n```\nin which case the 'kl.js' file would contain...\n```\n\"use strict\";\nmodule.exports = kl: {\n    hello: \"nuqneH\",\n    goodbye: \"DaH jImej\"\n};\n```\n\nNote: you may not want all your text to be changed during debug mode, such as URLs. Simply wrap the string in an array, and it will be ignored by the `debug_prefix` or `debug_suffix` wrappers, e.g.\n```\n\"use strict\";\nmodule.exports = en: {\n    admin_url: [\"/myadmin/subpage\"],//this will not be wrapped during debugging\n    admin_title: \"My admin Subpage\" //this will\n};\n```\n\n#### dictionary: default\nIncludes a very basic starter! Keep these items in your language files for nice debug output.\n```\ndictionary: {\n    en: {\n      module_language: [\"Txty language set to \"],\n      module_thislang: [\"English\"],\n      module_debug_start: [\"###Txty debug mode is on. \"],\n      module_debug_end: [\"###Txty\"],\n      module_settings: [\"Settings are...\"],\n      module_test: \"Test\"\n    }\n}\n```\n\n### lang\nSets the language dictionary which **txty** should refer to. Must match one of those in your dictionary, e.g.\n`lang: \"kl\"`\nYou can change language at any time using init (see above)\n\n#### lang: default\n`lang: \"en\"`\n\n### debug\nTo help you identify any stray text which you may not yet have **txty**-fied, debug will wrap each txty.get() output with the prefix and suffix of your choice.\n\nNote: See above to exclude certain text from the debug wrapping.\n\n#### debug: default\ne.g. with the default settings...\n```\ndebug: true,\ndebug_prefix: \"\u003clang='\",\ndebug_suffix: \"'/\u003e\",\n```\nThis would change...\n```\nvar outputText = txty.get(\"homepage_download_button\")\n```\nfrom `Download Free Now!` to `\u003clang=Download Free Now!/\u003e`\n\n## License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftaff%2Ftxty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftaff%2Ftxty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftaff%2Ftxty/lists"}