Comments (10)
With model field a widget is instantiated only once on Django app start. This is how Django works. So your solution for your particular scenario seems to be correct.
from django-tinymce4-lite.
@op are you importing the gettext
or gettext_lazy
function as your _
alias?
from django-tinymce4-lite.
I'm closing this issue because of no follow-up.
from django-tinymce4-lite.
I think the question in my previous message was irrelevant, I mistunderstood the purpose of the screenshot: this is not an issue with _('Description')
in the OP’s code (we see it translated to Spanish in the screenshot), but with the language config of tinymce itself.
I now understand the bug report and agree with it. get_language_config calls django’s get_language
in TinyMCE.__init__
, but it should be done during rendering so that there is a current request with its specific language. (I saw the issue on a page served in French for a site that defaults to English.)
Please reopen!
from django-tinymce4-lite.
The problem is not that the language is looked up at import time!
I use tinymce in the admin only; the form object is created for each request, so TinyMCE.__init__
is called within a request context, and the language code is correct.
The problem is that my language code is fr
and language files available with TinyMCE are fr_FR.js
and fr_CH.js
. (For the record the differences between these two aren’t really country-specific terms, but different choices, mistakes and missing strings.)
I don’t want to change my language code; fr_FR
would be incorrect as the audience is in Québec, and I don’t want fr-CA
in URLs either. From django viewpoint, it is correct to define the available languages as fr
and en
.
A proper fix should probably be in TinyMCE itself. But for a quick fix, I’ve tried a small change in django-tinymce4-lite: change get_language_config to fallback to "code_CODE"
if language_file_exists(code)
is false.
This logic allows various configs to work:
source fr-fr → convert fr_FR → found file fr_FR.js
source fr-be → convert fr_BE → no file fr_BE.js → no file fr.js → found file fr_FR.js
source fr → convert fr → no file fr.js → found file fr_FR.js
from django-tinymce4-lite.
@romanvm This is an issue for all sites that don’t use lang+country codes.
Can you reopen and discuss my proposed fix?
from django-tinymce4-lite.
This is an issue for all sites that don’t use lang+country codes.
This is not true. E.g., a site with uk
country code works perfectly fine. I agree that this may be an issue when Django language code does not match the name of the corresponding TinyMCE translation file. The case of Django's 4-letter code -> TinyMCE's 2-letter code is easy one and it was addressed. But the reverse case is not that obvious because of so many possible 4-letter language codes. I understand that you may prefer fr_FR as the default, but you are not the only user and French is not the only language with country variations, and I don't see the point of addressing specific per-user cases in a generic package. For your case a workaround is pretty simple: just rename TinyMCE's translation file from fr_FR.js
to fr.js
.
from django-tinymce4-lite.
This is not true. E.g., a site with
uk
country code works perfectly fine.
Right, I misqualified my statement!
I understand that you may prefer fr_FR as the default, but you are not the only user
Well I don’t (my project using tinymce is for an audience in Québec, Canada) but choosing code_CODE
when code.js
does not exists seemed reasonable.
For your case a workaround is pretty simple: just rename TinyMCE's translation file from
fr_FR.js
tofr.js
.
Well I don’t control the TinyMCE files which are part of django-tinymce’s static files. If there was no other choice I could copy fr_FR.js
to fr.js
during deployment.
Thanks for the changes in 0bf1a65, I’ll use that to add custom language
settings directly in default profile or mce_attrs.
from django-tinymce4-lite.
but choosing code_CODE when code.js does not exists seemed reasonable.
I disagree. In a case when for some language multiple country-specific variants are available, like for French or German or even English, who will decide which country-specific variant should be considered as the "master" one? Personally, I don't know, and, I'm afraid, in some cases this choice may even be politically colored. So I don't want to make that choice.
from django-tinymce4-lite.
This should be fixed in v. 1.7.5. I'm closing this issue.
from django-tinymce4-lite.
Related Issues (20)
- Admin shows old tinymc HOT 6
- Changing setup parameters in TinyMCE config HOT 1
- Not working in Widget HOT 2
- embed social media HOT 1
- The big problem for productiong with fu*ked strings HOT 2
- how can i change color of text area in django-tinymce-4-lite? HOT 2
- issue Textfield shows html in production HOT 32
- How to add custom classes to specific elements? HOT 2
- i want set default fontsize and font family HOT 1
- Use django JSON serialization to support lazy gettext HOT 4
- Plans for TinyMCE 5 ? HOT 6
- Multiple Timymce toolbars settings HOT 6
- Lot of "debugging" errors HOT 15
- Insecure Content Security policy "unsafe-inline" required HOT 7
- Support for django 2.2 HOT 1
- ERROR: Reverse for 'tinymce-css' not found. HOT 1
- X-Frame-Options: “DENY” HOT 4
- s3 storage for uploaded images HOT 4
- Tinymce not working with ManifestStaticFilesStorage HOT 4
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 django-tinymce4-lite.