django-vuejs-translate
This project aims to translate messages inside vuejs code.
Initially this idea and code was designed by Alex Tkachenko
Generating translations
python manage.py jsmakemessages -v3 -e jinja,py,html,js,vue -jse js,vue -i node_modules && python manage.py makemessages -v3 -e jinja,py,html,js,vue -i node_modules
Installation
Update INSTALLED_APPS
INSTALLED_APPS = [
...
'vuejs_translate',
...
]
Add urls
from django.conf.urls.i18n import i18n_patterns
urlpatterns += i18n_patterns(
path('vuejs-translate', include('vuejs_translate.urls')),
)
Add script to templates
// preferred way to use proxy cache on translations
<script type="text/javascript" src!=exp("hashed_translation_url()")>
// Or use old style with basic url tag
<script type="text/javascript" src!=url('"vuejs_translate:js-i18n"')>
Add something like this your js.
import Vue from 'vue'
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
const messages = { current: window.django.catalog || {} }
Vue.prototype._ = function() {
return this.$t.apply(this, arguments)
}
export const i18n = new VueI18n({
locale: 'current',
messages,
silentTranslationWarn: true
})
Notes on cache
After 0.6 version library uses cache ONLY for hashed url.
It uses two-level cache system:
- Every hashed url cached by django for a month.
- If client ignores headers and sends a fetch - server returns last-modified etag.
You can diable cache with VUEJS_CACHE settings
# settings.py
VUEJS_CACHE = False
Metadata
Release files for django-vuejs-translate 0.6.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-vuejs-translate-0.6.4.tar.gz | 7.4 kB | Without provenance | Details for django-vuejs-translate-0.6.4.tar.gz |
Release files / django-vuejs-translate-0.6.4.tar.gz
| Download URL | django-vuejs-translate-0.6.4.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bddc8e3fb66eccf75dbecf518aaf65d9cdce7603a39b873da2834826c673b0f0
|
|
BLAKE2b-256 checksum How to use checksums |
e438044c94d2884fa459245dfb5fc1d578b21764ea631856ed572947a0b98e3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5
|
Security for django-vuejs-translate 0.6.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.