-
Notifications
You must be signed in to change notification settings - Fork 33
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
Error in gettext-parser after angular 6 upgrade #22
Comments
Error appears because of breaking changes in cli v6. They removed node shimming. |
@biesbjerg please update to the latest versions of angular and rxjs |
Sorry, I simply don’t have the time at the moment. You are welcome to submit a PR. |
@enavarro222 worked for me, thank you ! |
@enavarro222: instead of patching node modules in a post-install script, @rezonant suggests here to use tslint patch. Create an empty operator in file src/noop.js: // ngx-translate-po-http-loader hack: replace missing node modules by an empty operator
// @see https://github.com/biesbjerg/ngx-translate-po-http-loader/issues/22
export const NOOP = 0; Then update your tsconfig.json to use it instead of "sream" module: {
"compilerOptions": {
"paths": {
"stream": [
"noop"
]
}
}
} update: Build is ok now, but I get the following error on runtime: TypeError: superCtor is undefined[En savoir plus]
inherits_browser.js:5
./node_modules/gettext-parser/lib/poparser.js:446
... @see the original PR used as example: https://github.com/Chocobozzz/PeerTube/pull/742/files |
As this module requires gettext-parser which requires node itself, I end up by converting the po file to json using node before building the application (each time my po file is updated). The json is now integrated to my app and can be loaded using the simple http loader: https://github.com/ngx-translate/http-loader To ensure compatibility, the conversion is based on ngx-translate-po-http-loader itself: var path = require('path');
var fs = require('fs');
var gettext = require('gettext-parser');
let i18nBaseDir = path.join(__dirname, '../../../..', 'src/assets/i18n');
console.log(`Scan po files into "${i18nBaseDir}"`)
let poFiles = fs.readdirSync(i18nBaseDir).filter(function (elm) { return elm.match(/.*\.po/ig); });
poFiles.forEach(poFileName => {
convertPoToJson(i18nBaseDir, poFileName);
});
function convertPoToJson(i18nBaseDir, poFileName) {
var poFilePath = path.join(i18nBaseDir, poFileName);
console.log(`Process po file "${poFilePath}"`);
var poData = fs.readFileSync(poFilePath, 'utf8');
const translations = {};
const po = gettext.po.parse(poData, 'utf-8');
if (!po.translations.hasOwnProperty('')) {
return translations;
}
Object.keys(po.translations[''])
.forEach(key => {
const translation = po.translations[''][key].msgstr.pop();
if (key.length > 0 && translation.length > 0) {
translations[key] = translation;
}
});
let jsonFilePath = path.join(i18nBaseDir, poFileName.replace(/\.[^/.]+$/, '') + '.json');
console.log(`Generate json file "${jsonFilePath}"`);
fs.writeFileSync(jsonFilePath, JSON.stringify(translations));
} node scripts/dev/i18n/lib/i18n-po-to-json.js |
Does it means that I can't use to files in my spare app served by nginx |
It looks like the problem is coming from gettext-parser, so is not directly related to this package. Somebody has proposed a gettext-parser pull request . Try it. |
@biesbjerg I created a new PR like you proposed :) |
@RignonNoel is this the PR that addresses this issue? A related concern. This library seems a bit abandoned and people are still using it. What shall we do about it? |
Agreed. I just installed it then checked the issues, and now I'm uninstalling it without ever getting started. |
@bluebaroncanada It doesn't mean the library doesn't do its job -it actually does. My comment was more about 'what do we do to keep this chunk of SW alive?' |
@sergiojoker11 Yes, it's this PR #26. I wait for an approval of @biesbjerg. The It's always the same things, you have multiple choice :
For this package i'm on phase 1, but since i need it and i don't have an answer it's possible that i propose an official support for a fork of this package if it continue. |
Since @biesbjerg didn't answer in the last 6 month despite the fact we have a fix since 2 month i created a fork of the project here : https://www.npmjs.com/package/@fjnr/ngx-translate-po-http-loader My company will support officially the package, so feel free to redirect your issues on this new fork if you have some in waiting. |
Thanks a lot @RignonNoel, you should create a PR on https://github.com/ngx-translate/core#plugins to change the plugins link to point to your fork. |
Couldn't immediately find the link to the github repo for the fork, so for others reading the thread above, it might be interesting to know as well that the fork lives here: |
Thanks to all, but i tested all provided solutions and still not working for me! |
Can you be more precise ? Do you have a specific error ? |
@RignonNoel No, it's the same! |
After upgrading to Angular 6 and RXJS 6 I receive the following error after
ng serve
ERROR in ./node_modules/@biesbjerg/ngx-translate-po-http-loader/node_modules/gettext-parser/lib/poparser.js
Module not found: Error: Can't resolve 'stream' in '../node_modules/@biesbjerg/ngx-translate-po-http-loader/node_modules/gettext-parser/lib'
The text was updated successfully, but these errors were encountered: