Comments (2)
Translating English Django Application to French language
The following steps could be applied to other languages as well
-
Install gettext on the host computer(GNU Internationalization utilities)
sudo apt-get update -y
sudo apt-get install -y gettext
or
apk update
apk add gettext -
settings.py
2.1 from django.utils.translation import ugettext_lazy as _
2.2 USE_I18N = True
2.3 LANGUAGE_CODE = 'en' or 'en-us'
2.4 LANGUAGES = (
('en', _('English')),
('fr', _('French')),
)2.5 add 'django.middleware.locale.LocaleMiddleware', between session and common middlewares
2.6. LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
) -
mkdir locale
locale must be at a sibling to django project folder -
Add {% load i18n %} at top of each template file
-
add from django.utils.translation import gettext as _ in a file where a template is returned
-
Text to be translated must be prefixed by "" character
e.g.
context = {"content":("This is text is in French language.")}
return render(request, 'sample.html', context) -
Create .po file
run /usr/src/app # /usr/local/bin/django-admin compilemessages -
Edit .po file and insert French text
I use https://www.translate.com/english-french for testing purposes -
run /usr/src/app # /usr/local/bin//django-admin makemessages -l fr
-
Change default setting language to French on your browser
from opendrr.
Complete for OpenQuake GeoViewer. Will keep open for other platform components.
from opendrr.
Related Issues (20)
- Publish FGP NHSL collection - Level 1
- Search function for documents hosted on OpenDRR and DRRPathways.ca
- Google Safe Browsing falsely determines opendrr.github.io as "Deceptive site" (detected phishing) HOT 5
- User stories for Kibana Dashboard
- Get OpenQuake to run in GitHub Actions with a sample dataset HOT 5
- opendrr.github.io misclassified as malicious by some security scanners (and blocked by CIRA Canadian Shield DNS servers) HOT 15
- Investigate whether DVC is a good alternative to Git LFS HOT 1
- Disclaimer for OpenDRR datasets and code HOT 3
- Check for bilingual README and LICENSE; generate PR if necessary HOT 8
- Standard Operating Procedure: Metadata Additions & Edits
- Autobuild Docker images and push to GitHub Container registry using GitHub Actions
- Move current data repo files to download repo and archive data
- Security Control SI-7 - Software, Firmware, and Information Integrity HOT 1
- Document the use of GitHub Actions/Workflows in OpenDRR
- Calculate Git LFS data (storage) usage for each repo
- GitHub Actions runner: overriding workdir for container jobs
- Set up Snyk Container to detect vulnerabilities in container images
- Set up automated Amazon EBS snapshot on a schedule
- Trigger for github actions to be run with workflow_dispatch HOT 1
- Collect traffic metrics for RiskProfiler and associated downloads and GitHub Pages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opendrr.