remig/web_lic

Circular import prevents translation of prettyPrint

mried opened this issue · 2 comments

mried commented

Hi,

I've tried to translate the prettyPrint function in util.js. To get access to LocaleManager.translate(), I had to insert the following import:

import LocaleManager from './translate';

Doing so prevents the site to load:

Uncaught TypeError: Cannot read property 'forOwn' of undefined
    at Object../src/storage.js (storage.js:30)
    at __webpack_require__ (bootstrap:54)
    at Object../src/uiState.js (uiState.js:1)
    at __webpack_require__ (bootstrap:54)
    at Object../src/translate.js (translate.js:1)
    at __webpack_require__ (bootstrap:54)
    at Object../src/util.js (util.js:1)
    at __webpack_require__ (bootstrap:54)
    at Object../src/ui.js (ui.js:1)
    at __webpack_require__ (bootstrap:54)

So the imports are ui -> util -> translate -> uiState -> storage. The one I inserted is translate. When storage is imported, it calls _.forOwn() which is not yet available because util is not executed completely.

Any ideas how to solve this?

Malte

remig commented

util.prettyPrint is bad; it was a very early attempt at some simple string lookup / translation logic. I just pushed a change that removes it entirely. Everything that relied on prettyPrint now passes through the translation lookup, for easy translations. There's more new strings to translate now.

mried commented

Great, I'll add the translations and collect every translation related change into one pull request. If you like, I can start the pull request as soon as I've done some changes and then add more and more commits. So you can see whats going on there.