{"id":18789617,"url":"https://github.com/joelalejandro/dicse","last_synced_at":"2025-09-10T01:35:07.657Z","repository":{"id":12103704,"uuid":"14692632","full_name":"joelalejandro/Dicse","owner":"joelalejandro","description":"A straight-forward translation engine for ASP.NET MVC.","archived":false,"fork":false,"pushed_at":"2013-12-20T23:59:14.000Z","size":139,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-29T06:48:03.301Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/joelalejandro.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}},"created_at":"2013-11-25T17:24:48.000Z","updated_at":"2013-12-20T23:59:15.000Z","dependencies_parsed_at":"2022-09-04T00:24:09.676Z","dependency_job_id":null,"html_url":"https://github.com/joelalejandro/Dicse","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/joelalejandro/Dicse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2FDicse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2FDicse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2FDicse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2FDicse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joelalejandro","download_url":"https://codeload.github.com/joelalejandro/Dicse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joelalejandro%2FDicse/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263901592,"owners_count":23527438,"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-07T21:08:06.103Z","updated_at":"2025-07-06T12:37:13.217Z","avatar_url":"https://github.com/joelalejandro.png","language":"C#","readme":"Dicse\n=====\n\nA straight-forward translation engine for ASP.NET MVC.\n\n## Dependencies\n\nNewtonsoft.Json \u003e= 5.0.8\n\n## Installation\n\nInstall the NuGet package:\n\n\u003cpre\u003e\u003ccode\u003ePM\u0026gt; Install-Package Dicse\u003c/code\u003e\u003c/pre\u003e\n\n## Creating a dictionary\n\nDicse currently supports two dictionary formats: JSON and XML. Each dictionary contains one language,\nand multiple contexts.\n\nYou'd use the context for translating the same word under different subjects. For instance, the word\n`bit` can be interpreted as the basic unit of information in computing or as a tiny piece of something.\nThus, you'd use the global context for the default behaviour, and a different context for the specific\nmeaning.\n\nAlso, contexts allow you to group translation keys by subject or by anything that suits you best.\n\n### The JSON dictionary\n\n\u003cpre\u003e\u003ccode\u003e{\n  \"Language\": \"es-es\",\n  \"Translations\": {\n    \"global\": {\n      \"Hello\": \"Hola\",\n      \"Goodbye\": \"Adiós\",\n      \"Hello {0}\": \"Hola {0}\"\n    },\n    \"family\": {\n      \"Hello\": \"Hey, qué tal?\",\n      \"Goodbye\": \"Hasta luego!\"\n    }\n  }\n}\u003c/code\u003e\u003c/pre\u003e\n\n### The XML dictionary\n\u003cpre\u003e\u003ccode\u003e\u0026lt;?xml version=\"1.0\"\u003e\n\u0026lt;translations language=\"es-es\"\u003e\n  \u0026lt;contexts\u003e\n    \u0026lt;context id=\"global\"\u003e\n      \u0026lt;entry key=\"Hello\" translated=\"Hola\"/\u003e\n      \u0026lt;entry key=\"Goodbye\" translated=\"Adiós\"/\u003e\n      \u0026lt;entry key=\"Hello {0}\" translated=\"Hola {0}\"/\u003e\n    \u0026lt;/context\u003e\n    \u0026lt;context id=\"family\"\u003e\n      \u0026lt;entry key=\"Hello\" translated=\"Hey, qué tal?\"/\u003e\n      \u0026lt;entry key=\"Goodbye\" translated=\"Hasta luego!\"/\u003e\n    \u0026lt;/context\u003e\n  \u0026lt;/contexts\u003e\n\u0026lt;/translations\u003e\n\u003c/code\u003e\u003c/pre\u003e\n\n## Configuring Dicse\n\nIn order for Dicse to work, the dictionaries must be loaded first.\n\nA recommended way to do this is to create a `TranslatorConfig` class in the `App_Start` folder\nof your MVC project, containing the following:\n\n\u003cpre\u003e\u003ccode\u003epublic class TranslatorConfig\n{\n    public static void ConfigureTranslations(Translator t)\n    {\n        // Load a translation file.\n        t.LoadFromFile(\"~/Translations/es-ar.json\");\n        \n        // Set a default language.\n        t.DestinationLanguage = \"es-ar\";\n    }\n}\u003c/code\u003e\u003c/pre\u003e\n\nAfterwards, you must call the `ConfigureTranslations` method in your `Global.asax` file:\n\n\u003cpre\u003e\u003ccode\u003epublic class MvcApplication : System.Web.HttpApplication\n{\n    protected void Application_Start()\n    {\n        // ... all other inits ...\n        \n        TranslatorConfig.ConfigureTranslations(JsonTranslator.Default);\n        // or\n        TranslatorConfig.ConfigureTranslations(XmlTranslator.Default);\n    }\n}\u003c/code\u003e\u003c/pre\u003e\n\nIn the `Application_Start` event, you must define which translator engine to use (JSON or XML). *You cannot mix\nbetween dictionary formats, you must pick one.*\n\n## Localizing your text\n\nTo use Dicse in your views, simply use the `Translate` method in the `Html` helper:\n\n\u003cpre\u003e\u003ccode\u003e@Html.Translate(\"Hello\")\u003c/code\u003e\u003c/pre\u003e\n\nYou can also translate with tokens:\n\n\u003cpre\u003e\u003ccode\u003e@Html.Translate(\"Hello {0}\", \"John Doe\")\u003c/code\u003e\u003c/pre\u003e\n\nIf you need to reference a specifix context, prepend the context name along with a pipe (|) to the translation key:\n\n\u003cpre\u003e\u003ccode\u003e@Html.Translate(\"family|Hello\")\u003c/code\u003e\u003c/pre\u003e\n\nYou must include `@using Dicse.Json;` or `@using Dicse.Xml;` at the top of your view so Razor can recognise the\nextension methods of `HtmlHelper`.\n\n### Optional: Register the Dicse namespace in your Razor Views web.config file\n\nIf you want to avoid having to add the `@using Dicse.Json;` or `@using Dicse.Xml;` on every view you wish to\ntranslate, you must register the Dicse namespace on the `\u003cpages\u003e` section of `Views/web.config`:\n\n\u003cpre\u003e\u003ccode\u003e\u0026lt;system.web.webPages.razor\u003e\n  \u0026lt;host factoryType=\"System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\" /\u003e\n  \u0026lt;pages pageBaseType=\"System.Web.Mvc.WebViewPage\"\u003e\n    \u0026lt;namespaces\u003e\n      \u0026lt;!-- \n      ...\n      ...\n      other namespaces\n      ...\n      ... --\u003e\n      \u0026lt;add namespace=\"Dicse.Json\" /\u003e \u0026lt;!-- or \u0026lt;add namespace=\"Dicse.Xml\" /\u003e --\u003e\n    \u0026lt;/namespaces\u003e\n  \u0026lt;/pages\u003e\n\u0026lt;/system.web.webPages.razor\u003e\u003c/code\u003e\u003c/pre\u003e\n\n**Important:** If you have your view file open while performing the forementioned changes to the Web.config file,\n**close** all view files and then reopen them, otherwise Razor won't recognise the `Translate` method.\n\n## License\n\nDicse is licensed under the MIT License.\n\n## Contribute\n\nFeel free to fork this project, report issues and propose pull requests!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelalejandro%2Fdicse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoelalejandro%2Fdicse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoelalejandro%2Fdicse/lists"}