{"id":13502006,"url":"https://github.com/derkan/flask-locale","last_synced_at":"2026-01-16T20:42:20.430Z","repository":{"id":57430445,"uuid":"43960012","full_name":"derkan/flask-locale","owner":"derkan","description":"Implements i18n and l10n support for Flask.","archived":false,"fork":false,"pushed_at":"2021-10-20T14:23:28.000Z","size":24,"stargazers_count":42,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-01T17:16:51.285Z","etag":null,"topics":["flask","flask-locale","i18n","json","python","python3"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/derkan.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":"2015-10-09T14:18:57.000Z","updated_at":"2023-04-20T08:02:42.000Z","dependencies_parsed_at":"2022-08-26T05:02:01.863Z","dependency_job_id":null,"html_url":"https://github.com/derkan/flask-locale","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/derkan/flask-locale","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fflask-locale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fflask-locale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fflask-locale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fflask-locale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derkan","download_url":"https://codeload.github.com/derkan/flask-locale/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derkan%2Fflask-locale/sbom","scorecard":{"id":335702,"data":{"date":"2025-08-11","repo":{"name":"github.com/derkan/flask-locale","commit":"f94e1bb6bcbd658f1c729ec6de58a8a4f5afd86d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENCE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-66 / GHSA-562c-5r94-xh97","Warn: Project is vulnerable to: PYSEC-2019-179 / GHSA-5wv5-4vpf-pj6m","Warn: Project is vulnerable to: PYSEC-2023-62 / GHSA-m2qf-hxjv-5gpq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T04:40:18.312Z","repository_id":57430445,"created_at":"2025-08-18T04:40:18.313Z","updated_at":"2025-08-18T04:40:18.313Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["flask","flask-locale","i18n","json","python","python3"],"created_at":"2024-07-31T22:01:58.193Z","updated_at":"2026-01-16T20:42:20.396Z","avatar_url":"https://github.com/derkan.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Flask-Locale\n\nImplements i18n and l10n support for Flask.  This is based on the old [Flask-Locale](http://github.com/whtsky/whtsky-locale/) extension. Uses files or database to get translations.\n\nYou can use this extension to translate your applications really easily. No babel preperation is needed. Just put your English text and its translation in a file.\n\n## Install\n\n```sh\npip install Flask-Locale\n```\n\n## Quick Start\n- Py3 ready\n- For very quick test look at `demo` directory.\n\n- Create a directory `translations` at app root. \n- Create file `translations/tr_TR.csv` with this content:\n\n```csv\n\"Hello %(name)s\",\"Merhaba %(name)s\"\n\"Hello\",\"Merhaba\"\n```\n- Create `templates` directory at app root.\n\n- Create `locale.html` file with this content:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003ctitle\u003eFlask-Locale\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n \u003ch2\u003eTranslate with parameters in template\u003c/h2\u003e\n {{ _('Hello %(name)s', name=name) }}\n \u003cbr\u003e\n \u003ch2\u003eTranslated in Python Code:\u003c/h2\u003e\n {{ py_translated }}\n\u003c/body\u003e\n\u003c/html\u003e\n```\n-- Create your application main file `demo.py`:\n\n```py\n# -*- coding: utf-8 -*-\n\nfrom flask import Flask, request, render_template, g\nfrom flask_locale import Locale, _\n\napp = Flask(__name__)\napp.config['LOCALE_PATH'] = 'translations'\n\nlocale = Locale(app)\n\n\n@locale.localeselector\ndef get_locale():\n    # if a user is logged in, use the locale from the user settings\n    user = getattr(g, 'user', None)\n    if user is not None:\n        return user.locale\n    # otherwise try to guess the language from the user accept\n    # header the browser transmits.  We support tr/fr/en in this\n    # example.  The best match wins.\n    return request.accept_languages.best_match(['tr_TR', 'fr_FR', 'en_US'])\n\n\n@app.route(\"/\")\ndef index():\n    # How we do translation in python code:\n    py_translated = _('Hello')\n    # How we do translation in template:\n    return render_template('locale.html', name='Erkan', py_translated=py_translated)\n\n\nif __name__ == '__main__':\n    app.run(debug=True)\n\n```\n\n- Run yout app:\n\n```sh\npython demo.py\n```\n\n- Now access your app: `http://127.0.0.1:5000/`\n\n## Usage\n\n### Loading translations from a file:\nLoads translations from CSV files having locale extension in a directory. File should be `utf-8` encoded.\n\nTranslations are strings with optional Python-style named placeholders (e.g., ``\"My name is %(name)s\"``) and their associated translations.\n\nThe directory should have translation files of the form filename: LOCALE, e.g.  tr_TR. \n\nTranslation files should have two or three columns: string, translation, and an optional plural indicator. Plural indicators should be one of ``\"plural\"`` or ``\"singular\"``. \n\nA given string can have both singular and plural forms. For example ``\"%(name)s liked this\"`` may have a different verb conjugation depending on whether %(name)s is one name or a list of names. There should be two rows in the CSV file for that string, one with plural indicator \"singular\", and one \"plural\".\n\nFor strings with no verbs that would change on translation, simply\nuse ``\"unknown\"`` or the empty string (or don't include the column at all).\n\nThe file is read using the csv module in the default \"excel\" dialect.\nIn this format there should not be spaces after the commas.\n\nExample translation tr_TR.csv::\n\n```\n\"I love you\",\"Seni seviyorum\"\n\"%(name)s liked these\",\"A %(name)s bunları sevdi\",\"plural\"\n\"%(name)s liked this\",\"A %(name)s bunu sevdi\",\"singular\"\n```\n\n### Loading translations from database:\n\n```py\n@locale.db_loader\ndef get_translations():\n    \"\"\"Translations selector for db\"\"\"\n        sql = select(\n            [Locale.c.code, TranslationKey.c.name, Translation.c.translated, Translation.c.singular],\n            from_obj=[Locale.join(Translation).join(TranslationKey)])\n        q = db.session.execute(sql)\n        data = q.fetchall()\n        q.close()\n    return list(data)\n```\n\n### Reloading translations\n\nWhen user's locale is changed, call `refresh()` method:\n\n```py\nuser.locale = request.form['locale']\nlocale.refresh()\nflash(_('Language is changed'))\n```\n\n### Translate Functions\n\n`translate()` (or its alias `_()`) method does a lazy translation, that means its actual translate function is called when you access it. So you can use translate functions in your forms before Flask-Locale is initialized.\n\n\n```py\nfrom flask.ext.wtf import Form\nfrom wtforms.fields import TextField, PasswordField\nfrom wtforms.validators import Required, Email\nfrom extensions import _\n\nclass EmailPasswordForm(Form):\n    email = TextField(_('Email'), validators=[Required(), Email()])\n    password = PasswordField(_('Password'), validators=[Required()])\n```\n\nIf you want immediate translation, use `do_translate` method.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderkan%2Fflask-locale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderkan%2Fflask-locale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderkan%2Fflask-locale/lists"}