parndt / refinerycms-wymeditor

WYMeditor extension for Refinery CMS

Home Page:http://refinerycms.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

/wymeditor/lang/zh-TW.js not found

arthurtalkgoal opened this issue · comments

When I update the latest version, my refinerycms editor return

/wymeditor/lang/zh-TW.js not found error.

I check out the console, zh-TW.js was stored as "zh_tw.js":
~/.rvm/gems/ruby-2.0.0-p353@rails4/bundler/gems/refinerycms-wymeditor-4aa3df90cc37/app/assets/javascripts/wymeditor/lang
bg.js da.js es.js fr.js it.js nb.js pl.js rs.js sl.js vi.js
ca.js de.js fa.js he.js ja.js nl.js pt-BR.js ru.js sv.js zh_cn.js
cs.js en.js fi.js hu.js lv.js nn.js pt.js sk.js tr.js zh_tw.js

Can the zh_tw.js rename to zh-TW , like 'pt-BR.js' (so as zh_cn.js) ?

Are you using Rails 4.x? There can be another problem. Assets are not precompiled without fingerprint there. You can look at https://github.com/alexspeller/non-stupid-digest-assets (don't care about that offensive name). Those files should live simply in public. So maybe it is not problem with file name case, but it can be also. This problem should appear only in production mode. Can you confirm?

Thanks simi,
Yup, I am using Rails 4
I've tried the non stupid digest assets, but seems not working either.

How can I add the fingerprint to the files?

However, I have pull request the update since the "zh_ch" pattern is not consistent with the Standard locale anyway

-WYMeditor.STRINGS['zh_cn'] = {
+WYMeditor.STRINGS['zh-CN'] = {

After the rename, I still get the error js file not found,i tried the following:

http://mydomain/assets/wymeditor/lang/zh-TW.js
not found
http://mydomain/javascripts/wymeditor/lang/zh-TW.js (wymeditor generated this include)
not found

http://mydomain/assets/wymeditor/lang/en.js
found!

Very strange!

I'm experiencing a similar issue:

Referencing the edge version of refinerycms-wymeditor from the Gemfile, it can't find /assets/wymeditor/lang/it.js, so the buttons aren't translated and I get this error from the developer console:

"NetworkError: 404 Not Found - http://example.com/assets/wymeditor/lang/it.js"

@darmenise
In production, I have the same problem for the Russian language.

Precompilation changes file names to similar ones:

-rw-rw-r-- 1 deployer deployer 3699 фев 17 10:53 ru-0f607cd2e95f44f70d536d937c51ad8c99810127b9151fcd143f602c0b5183f9.js
-rw-rw-r-- 1 deployer deployer  916 фев 17 10:53 ru-0f607cd2e95f44f70d536d937c51ad8c99810127b9151fcd143f602c0b5183f9.js.gz
-rw-rw-r-- 1 deployer deployer 1530 фев 17 10:53 sk-788b7eee5149f793ddc3f7393de805ef948bbe35f2a620aaf7b25db3f3ff84ff.js
-rw-rw-r-- 1 deployer deployer  797 фев 17 10:53 sk-788b7eee5149f793ddc3f7393de805ef948bbe35f2a620aaf7b25db3f3ff84ff.js.gz
-rw-rw-r-- 1 deployer deployer 1106 фев 17 10:53 sl-2e6c7ae4347117cfdee701ea997efc86416873c9415cbf205751acfcb27b68fa.js
-rw-rw-r-- 1 deployer deployer  615 фев 17 10:53 sl-2e6c7ae4347117cfdee701ea997efc86416873c9415cbf205751acfcb27b68fa.js.gz

And the code in JS expects ru.js

I accepted @simi advice, and it helped me

#Gemfile
gem "non-stupid-digest-assets"
# config/initializers/non_digest_assets.rb
NonStupidDigestAssets.whitelist += [/wymeditor\/lang\/.*/]

After the necessary localization localization files will lie next to the precompiled:

-rw-rw-r-- 1 deployer deployer 3699 фев 17 10:53 ru-0f607cd2e95f44f70d536d937c51ad8c99810127b9151fcd143f602c0b5183f9.js
-rw-rw-r-- 1 deployer deployer  916 фев 17 10:53 ru-0f607cd2e95f44f70d536d937c51ad8c99810127b9151fcd143f602c0b5183f9.js.gz
-rw-rw-r-- 1 deployer deployer 3699 фев 17 10:53 ru.js
-rw-rw-r-- 1 deployer deployer  916 фев 17 10:53 ru.js.gz
-rw-rw-r-- 1 deployer deployer 1530 фев 17 10:53 sk-788b7eee5149f793ddc3f7393de805ef948bbe35f2a620aaf7b25db3f3ff84ff.js
-rw-rw-r-- 1 deployer deployer  797 фев 17 10:53 sk-788b7eee5149f793ddc3f7393de805ef948bbe35f2a620aaf7b25db3f3ff84ff.js.gz
-rw-rw-r-- 1 deployer deployer 1530 фев 17 10:53 sk.js
-rw-rw-r-- 1 deployer deployer  797 фев 17 10:53 sk.js.gz
-rw-rw-r-- 1 deployer deployer 1106 фев 17 10:53 sl-2e6c7ae4347117cfdee701ea997efc86416873c9415cbf205751acfcb27b68fa.js
-rw-rw-r-- 1 deployer deployer  615 фев 17 10:53 sl-2e6c7ae4347117cfdee701ea997efc86416873c9415cbf205751acfcb27b68fa.js.gz
-rw-rw-r-- 1 deployer deployer 1106 фев 17 10:53 sl.js
-rw-rw-r-- 1 deployer deployer  615 фев 17 10:53 sl.js.gz

I don't want to sound crass considering Refinery is free and all, but the fact that the bundled editor doesn't properly work with other languages than English is kind of a big deal, isn't it, considering the Refinery website is proud of its robust i18n support?

In my not-so-humble opinion, the non-stupid-digest-assets workaround should either be part of the README or the bug should be fixed. The fact that you have to google extensively to get to this issue thread should be unnecessary.

To the bug itself, this line definitely doesn't work with asset digest URLs:

eval($.ajax({url:wym._options.langPath + wym._options.lang + '.js', async:false}).responseText);

Referencing the full asset path (with digest) from inside a block of javascript is basically impossible, so you have to work around this by using Sprockets, right?

Also, this one looks suspicious, but it might be unrelated to this bug, considering English works:

LANG_DEFAULT_PATH : "<%= Rails.application.config.assets.prefix + '/wymeditor/lang/en.js' %>",

I tried this now "<%= asset_path("wymeditor/lang/#{I18n.locale}") %>" and it seems to work. See pull request: #54

@evenreven yeah, that is one of the reasons I extracted it, so that people could use whichever editor.