Comments (9)
@martinroob @martinsik Can't we add a pretty-xml
call on the output before writing in the final xlf file ? (@martinroob thanks for your work btw !)
from ngx-i18nsupport.
This should be possible. I will have a look at it
from ngx-i18nsupport.
@martinsik I'm confronted to the same issue. I solve this by apply a little home made js script on the xlf files :
const replace = require('replace-in-file');
const format = require('xmlfmt');
const fs = require('fs');
const xlfFilesPath = 'src/i18n/*.xlf';
// Remove leading and trailing whith space
const filesChanges1 = replace.sync({
files: xlfFilesPath,
from: [/^\s*/gm, /\s*$/gm],
to: ''
});
// Remove \n to put all in 1 line
const filesChanges2 = replace.sync({
files: xlfFilesPath,
from: /\n/gm,
to: ''
});
// Format xml files
[
'src/i18n/messages.xlf',
'src/i18n/messages.en.xlf',
'src/i18n/messages.fr.xlf'
].forEach(file => {
fs.writeFileSync(file, format(fs.readFileSync(file, 'utf8')));
});
It need replace-in-file
and xmlfmt
to work.
from ngx-i18nsupport.
Starting with version 0.16.0 there is a new configuration parameter beautifyOutput
. When it is set to true
now pretty-data
(the library beyond pretty-xml) will be used to format the output.
from ngx-i18nsupport.
Hi,
in principle you are absolutely right.
Unfortunately the output is just what the library I use for xml handling (xmldom) gives.
There is no good formatter available at the moment. At least I do not know one.
So I am sorry that I cannot correct this. Maybe later.
Instead of translating manually by editing the ugly xml file you should think about using a translation tool (TinyTranslator is the one I suggest if course)
from ngx-i18nsupport.
@evanliomain I ended up using the following command to prettify the output:
npm i --save-dev pretty-xml
And then the following:
cat src/locale/messages.zh.xlf | node node_modules/.bin/pretty-xml > src/locale/messages.zh.xlf-new && rm src/locale/messages.zh.xlf && mv src/locale/messages.zh.xlf-new src/locale/messages.zh.xlf
from ngx-i18nsupport.
@martinroob Awesome ! Thanks a lot !
from ngx-i18nsupport.
@martinsik I'm confronted to the same issue. I solve this by apply a little home made js script on the xlf files :
const replace = require('replace-in-file'); const format = require('xmlfmt'); const fs = require('fs'); const xlfFilesPath = 'src/i18n/*.xlf'; // Remove leading and trailing whith space const filesChanges1 = replace.sync({ files: xlfFilesPath, from: [/^\s*/gm, /\s*$/gm], to: '' }); // Remove \n to put all in 1 line const filesChanges2 = replace.sync({ files: xlfFilesPath, from: /\n/gm, to: '' }); // Format xml files [ 'src/i18n/messages.xlf', 'src/i18n/messages.en.xlf', 'src/i18n/messages.fr.xlf' ].forEach(file => { fs.writeFileSync(file, format(fs.readFileSync(file, 'utf8'))); });It need
replace-in-file
andxmlfmt
to work.
Thanks
from ngx-i18nsupport.
Just here to say that I was totally missed this parameter. At least I found it now. This is gold. I was really frustrating with earlier dirty style how those files looks like. It was really hard to merge files and read them and edit them because there were several translations all in one line. Thank you for this feature.
from ngx-i18nsupport.
Related Issues (20)
- How to use xliffmerge with custom webpack config? HOT 1
- is not a directory error HOT 1
- xliffmerge: use official Angular v9 i18n config HOT 5
- Flag to keep manually added translations HOT 3
- ngx-i18nsupport dynamically language switcher on the dropdown list selection? HOT 1
- '>' are not escaped by the XmlSerializer HOT 1
- Auto Translate with $localize delete variables. HOT 4
- Package "@ngx-i18nsupport/tooling" has an incompatible peer dependency to "@angular/core" /"@angular/common" when updating to angular 10.0.0 HOT 7
- Source being pulled from node_modules HOT 1
- Problem running the npm script HOT 2
- How to know which item failed HOT 2
- $localize usage in component is reset on every extraction HOT 4
- xliffmerge overwrites source if different
- Arabic auto translate problem with xliffmerge
- Angular 10 not supporting xliffmerge HOT 10
- Online version broken
- Extraction stopped working after Angular upgrade 12 -> 13 HOT 17
- Xliff merge issue HOT 2
- Angular 16 Package has unmet peer dependencies HOT 1
- 403: User Rate Limit Error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-i18nsupport.