Opened 9 years ago
Closed 9 years ago
#15057 closed defect (fixed)
custom build breaks i18n bundles with dojo 1.7.2
Reported by: | waltercacau | Owned by: | Rawld Gill |
---|---|---|---|
Priority: | high | Milestone: | 1.7.3 |
Component: | BuildSystem | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
Internationalization bundles generated by a custom build are broken with dojo 1.7.2 . The i18n plugin works fine if I don't use the build system.
I created a simple forked project based on a dojo-boilerplate project hosted on github that illustrates the issue.
If you have git and python in a unix box, you can get up and running running the following commands in the terminal:
git clone --recursive git://github.com/waltercacau/dojo-boilerplate.git
cd dojo-boilerplate
./build.sh
python -m SimpleHTTPServer
Then access the unbuilt version at http://localhost:8000/src/ . Note that it respects the dojo.locale = "pt-br" as set in the data-dojo-config attribute of the script tag.
Now, access the built one at http://localhost:8000/dist/ and notice that it is showing in english. You can check in the browser's console that dojo.locale is "pt-br".
I am using an Ubuntu 10.04.3 LTS Lucid box and tested with Firefox 9.0.1 and Google Chrome 17.
I spent some time to figure out the issue and found that the resource bundle was being evaluated through dojo/i18n.js evalBundle function. This function actually substitutes the define function by a little stub assuming that the file which is being loaded contains only one define call. But generated bundle contains a require call with a cache config property contaning the bundled i18n resources. So, when these resources are evaluated, they call the stub define and not the global one.
This is illustrated by the app/nls/pt-br/Messages.js . If you look in the browser console output, you will see the output of a call to "console.log('...', define)".
I am not sure what is the best way to fix it, but for now a simple workaround is to use window.define in i18n resources.
Attachments (1)
Change History (8)
Changed 9 years ago by
Attachment: | 0001-Fix-for-dojo-ticket-15057.patch added |
---|
comment:1 Changed 9 years ago by
comment:2 Changed 9 years ago by
Component: | General → BuildSystem |
---|---|
Owner: | set to Rawld Gill |
comment:4 Changed 9 years ago by
Milestone: | tbd → 1.7.3 |
---|---|
Priority: | undecided → high |
Status: | new → assigned |
comment:6 Changed 9 years ago by
Hi waltercacau! Thanks for your excellent report!
This is now working in trunk as of [28365]. I will backport to 1.7.3 before closing.
comment:7 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
If any i18n fixes are backported, they will all be backported as a single commit which will be tracked on #14092.
That's just a small patch generated using git for the 1.7.2 release that I found on github: ( https://github.com/dojo/dojo/tree/2e1e84ecd7829b9f17311ffb621fbfba27653aab ).
It solves the issue for my use case at least.