rubenv / angular-gettext-tools

Tools for extracting/compiling angular-gettext strings.
http://angular-gettext.rocketeer.be/
MIT License
39 stars 129 forks source link

Compile option for avoid the language key in the json generated #148

Closed HectorLS closed 4 years ago

HectorLS commented 8 years ago

Hi, when i compile a .po file i get the following :

{
  "es": {
    "Hello" : "Hola"
  }
}

Is there a compile option to avoid the language key and get this output ? :

{
  "Hello" : "Hola"
}

Gulp task :

gulp.task('potojson', function () {
  return gulp.src('./assets/languages/*.po')
    .pipe(gettext.compile({
        format: 'json'
        }))
    .pipe(gulp.dest('./dist/assets/languages/'));
});

I saw this List of angular-gettext tools but no one looks achieve that :S

       "startDelim": "{{",
        "endDelim": "}}",
        "markerName": "gettext",
        "markerNames": [],
        "moduleName": "gettextCatalog",
        "moduleMethodString": "getString",
        "moduleMethodPlural": "getPlural",
        "attribute": "translate",
        "attributes": [],
        "lineNumbers": true

Thanks in advance

dsnoeck commented 8 years ago

@Tibicenas Did you find a workaround ?

dsnoeck commented 6 years ago

Funny how I come back randomly to this post. Here is how we have integrate (in TypeScript):

public setLanguage(lang: string): void {
  this.gettextCatalog.setCurrentLanguage(lang);

  if (this.loadedLanguages.indexOf(lang) > -1) {
    this.$state.reload();
  } else {
    this.$http.get(`i18n/${lang}.json`).then(
      (response: any) => {
        this.gettextCatalog.setStrings(lang, response.data[lang]);
        this.loadedLanguages.push(lang);
        this.$state.reload();
      }
    );
  }
}