Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Support] /devel translations did not work #720

Closed
derpicknicker1 opened this issue Jan 15, 2015 · 9 comments
Closed

[Support] /devel translations did not work #720

derpicknicker1 opened this issue Jan 15, 2015 · 9 comments

Comments

@derpicknicker1
Copy link
Contributor

I wanted to enable translations in /devel branch. Started by using /?l10n=de but nothing happend.
Then i did the following steps:

python setup.py babel_refresh
python setup.py babel_compile
python setup.py install

Again nothing happend. So i started dev mode in chrome and the console told me, that /static/js/i10n/None.js was not found. I set a breakpoint to see if babel is initialized correctly. When i break in Line 4 in /static/js/app/main.js i can't see a window[BABEL_TO_LOAD_de] object. So it seems like babel cant refresh it's cacalog list in /server/__init__.py where g.locale is set (Line 89). So the de.js file can't be included in /templates/index.jinja2 at Line 212 (g.locale seems to be "None"). Thereby in Line 68 LOCALE also didn't get set correctly.

So it seems like babel did not find the language files. I looked at last build log. the language *.js files where copied within build. the *.po files not. Short look in setup files let me do this stepps:

in MANIFEST.in i added:

recursive-include src/octoprint/translations *

in setup.py i edited Line 286 to this:

package_data = {"octoprint": package_data_dirs('src/octoprint', ['static', 'templates', 'plugins', 'translations'])}

Then i recompiled babel files and build octoprint.

Now it seems to work. In break mode i can see window[LOCALE] set to 'de' and window[BABEL_TO_LOAD_de] holding a catalog.
Sadly nearly nothing is translated. The only non-english words i found are in the file browser.The "Uploaded:" time value is translated. Nothing else. See Picture[1].
Seems like babel cant find/open/load its translation files correctly.

Please help.

System: Beaglebone Black, "thing image"[2] running Amströng Linux 2014.06, Kernel 3.14.19, OctoVersion: 1.2.0-dev-404-gb0805a9-dirty (devel branch)

Octoprint Log didn't say anytihing.
I think Printermodel is not needed here, but i only have a replicape with nothing connected yet.

[1]
unbenannt

[2] http://wiki.thing-printer.com

foosel added a commit that referenced this issue Jan 15, 2015
…ation

Should solve initial problem reported in #720
@foosel
Copy link
Member

foosel commented Jan 15, 2015

Wow, that is pretty embarrassing, thanks for reporting this! That's been broken now since initial release of i18n and either nobody noticed or didn't bother to tell me - and I of course didn't notice myself since I usually run from my development folder. Jikes.

In any case, I've just fixed the problem of the translation files not being correctly included in the installation (see above commit with typo - yay). I tried on a fresh virtual environment and the files were installed successfully. However, they also work just fine for me when switching to Deutsch. I could imagine that you have a caching issue there since the highlighted string gets created on the fly from within Javascript whereas the rest of the page gets created from the templating code. Could you try a shift-reload in your browser and see if this fixes things for you?

@derpicknicker1
Copy link
Contributor Author

Shift-reload does not help. Seems like only the *.js files get loaded or the *.po files are broken or something like that.

@derpicknicker1
Copy link
Contributor Author

Chrome console also reports:

 GET http://192.168.1.2:5000/static/js/lib/underscore-min.map 404 (NOT FOUND)

But i don't think this is causing the translation issue.

EDIT:
Answer: http://stackoverflow.com/questions/18429625/missing-javascript-map-file-for-underscore-js-when-loading-asp-net-web-page

@foosel
Copy link
Member

foosel commented Jan 15, 2015

Nope, it isn't. Odd.. You are sure that you did not forget the python setup.py install again after fixing setup.py? Just to make sure, please try first uninstalling OctoPrint: pip uninstall OctoPrint then reinstalling it python setup.py install (make sure to use the correct python and pip binaries, if you have the OctoPrint instance installed into a virtual env, you need to use that). I agree that it sounds like it's completely ignoring anything that is in the po files while happily using what in the javascript file, but the po files should have been copied to your python's site-packages dir following the install command (you could also check that), and that did also work just fine when I tried a fresh checkout of devel in a fresh virtual environment just now.

@derpicknicker1
Copy link
Contributor Author

I uninstalled and re-installed it. But nothing changes. I also opened the page in firefox - what i have never done before - to see if it's a caching issue. No luck.
At the moment i can't understand why it's working for you and not for me.

EDIT:
just installed on fresh ubuntu 14.04 in x86 VM. Same problem
octoPrint in debug mode also didn't give a clue

@foosel
Copy link
Member

foosel commented Jan 16, 2015

Can you provide the exact commands you are using for installing? Maybe that way I can reproduce the behaviour.

Here's what I did:

git clone -b devel https://github.com/foosel/OctoPrint.git
cd OctoPrint
virtualenv myenv
./myenv/bin/python setup.py install
./myenv/bin/octoprint -b myconfig

image

@derpicknicker1
Copy link
Contributor Author

When i do it your way on ubuntu it runs.
On BBB i'm doing this:

git clone http://[...]OctoPrint.git
cd ~/OctoPrint
git pull && git checkout devel
python setup.py install
./run

Now i did it in virtualenv like you did and it works. I'm not very familar with python (and linux) to figure out why, but now everything seems to be fine :)

@foosel
Copy link
Member

foosel commented Jan 16, 2015

I'd expect that you'd need super user rights to write to the regular python installation (which is probably located somewhere under /usr/).

So maybe that's what went wrong and sudo python setup.py install would have been enough.

But the virtual env approach is cleaner anyways.

Ok if we close this now?

@derpicknicker1
Copy link
Contributor Author

Yes. It can be closed. sudo dit the trick. Now i have to understand why (as i said: new to Linux and Python 😄)
Thank you for your help!

@foosel foosel closed this as completed Jan 17, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants