Coder Social home page Coder Social logo

cohancarpentier / ngx-i18nsupport-lib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from martinroob/ngx-i18nsupport-lib

0.0 1.0 0.0 422 KB

A Typescript Library to work with Angular generated i18n files (xliff, xmb)

License: MIT License

JavaScript 0.64% TypeScript 99.36%

ngx-i18nsupport-lib's Introduction

Build Status Dependency Status devDependency Status Code coverage npm

ngx-i18nsupport-lib

A Typescript library to work with Angular generated i18n files (XLIFF Version 1.2 and 2.0, XMB)

Table of Contents

Introduction

Installation

npm install ngx-i18nsupport-lib --save-dev

Usage

TranslationMessagesFileFactory

This class is the entry point of the library. You can use TranslationMessagesFileFactory to load Angular generated message files. The format of the files can be XLIFF 1.2, XLIFF 2.0 or XMB.

It returns a format independent abstraction of the file content, which is described in the interfade ITranslationMessagesFile

Example

// Usage of fromFileContent to read a file with a known format
let filename = ...;
let encoding = 'UTF-8';
let content = fs.readFileSync(filename, encoding);
let file: ITranslationMessagesFile
  = TranslationMessagesFileFactory.fromFileContent('xlf', content, filename, encoding);
console.log(Utils.format('Translation from %s to %s', 
    file.sourceLanguage(),
    file.targetLanguage()));
file.forEachTransUnit((tu: ITransUnit) => {
  console.log(tu.sourceContent());
});

You can also use fromUnknownFormatFileContent to read a file of any supported format. The library will detect the correct file format:

...
let file: ITranslationMessagesFile
  = TranslationMessagesFileFactory.fromUnknownFormatFileContent(content, filename, encoding);

ITranslationMessagesFile

A messages file.

For API details have a look at the interface.

ITransUnit

A single translation contained in the messages file.

For API details have a look at the interface.

Tests

npm test

This will run a testsuite that checks all relevant aspects of the library.

Contributing

I did not really think about contributions, because it is just a small experimental project.

But if you are interesting, send me an email, so that we can discuss it.

References

ngx-i18nsupport-lib's People

Contributors

martinroob avatar cohancarpentier avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.