JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1155
  • Score
    100M100P100Q115980F
  • License MIT

Phrase adapter for ngx-translate

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ngx-translate-phraseapp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    ngx-translate-phraseapp

    ngx-translate-phraseapp is the official library for integrating Phrase Strings In-Context Editor with ngx-translate in your Angular application.

    Ivy

    Since Angular 13 the View Engine has been removed, and since 1.0.0 the ngx-translate-phraseapp package uses new version of Angular which might cause old projects to break. In this case try major version 0 package of this repository.

    πŸ“œ Documentation

    Prerequisites

    To use ngx-translate-phraseapp with your application you have to:

    Demo

    You can find a demo project on GitHub.

    Installation

    NPM

    npm install ngx-translate-phraseapp

    Build from source

    You can also build it directly from source to get the latest and greatest:

    npm run dist

    Usage

    Configure

    import { initializePhraseAppEditor, PhraseConfig } from 'ngx-translate-phraseapp';
    
    let config: PhraseConfig = {
      projectId: '<YOUR_PROJECT_ID>',
      accountID: '<YOUR_ACCOUNT_ID>'
      phraseEnabled: true,
    };

    You can find the Project-ID in the Project overview in the Phrase Strings Translation Center. The Account-ID can be found in the Organization settings.

    By default, the In-Context Editor’s document parser converts all keys to lowercase. If you’re experiencing issues with this behavior and want to use case-sensitive keys within the In-Context Editor, consider disabling the automatic lowercase feature:

    let config: PhraseConfig = {
      // ...
      autoLowercase: false
    }

    Using the old version of the ICE

    To use the old version of ICE, use option useOldICE: true in your PHRASEAPP_CONFIG or integration options

    let config = {
      projectId: '<YOUR_PROJECT_ID>',
      accountID: '<YOUR_ACCOUNT_ID>',
      phraseEnabled: true,
      useOldICE: true,
    };
    
    initializePhraseAppEditor(config);

    Using the US Datacenter with ICE

    In addition to phraseEnabled, projectId and accountID in the config, also add the US specific URLs to enable working through the US endpoint.

      baseUrl: "https://us.app.phrase.com",
      apiBaseUrl: 'https://api.us.app.phrase.com/api/v2',
      oauthEndpointUrl: "https://api.us.app.phrase.com/api/v2/authorizations",
      profileUrl: "https://us.app.phrase.com/settings/profile",

    Code examples

    Add the following snippets to your Angular app:


    app.component.ts

    import { initializePhraseAppEditor, PhraseAppCompiler, PhraseConfig} from 'ngx-translate-phraseapp'
    
    let config: PhraseConfig = {
      projectId: '<YOUR_PROJECT_ID>',
      accountID: '<YOUR_ACCOUNT_ID>'
      phraseEnabled: true,
    };
    
    initializePhraseAppEditor(config);


    app.module.ts

    import { TranslateModule, TranslateLoader, TranslateCompiler } from '@ngx-translate/core';
    import { HttpClientModule, HttpClient } from '@angular/common/http';
    import { PhraseAppCompiler } from 'ngx-translate-phraseapp'
    import { AppComponent } from './app.component';
    
    
    export function HttpLoaderFactory(http: HttpClient) {
      return new TranslateHttpLoader(http);
    }
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: HttpLoaderFactory,
            deps: [HttpClient]
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: PhraseAppCompiler
          }
        }),
      ],
      providers: [],
      bootstrap: [AppComponent]
    })

    If this does not work for you, you can also integrate the JavaScript snippet manually.

    Using the US Datacenter with ICE

    In addition to phraseEnabled and projectId in the config, also add the US specific URLs to enable working through the US endpoint.

    let config: PhraseConfig = {
      // ...
      baseUrl: "https://us.app.phrase.com",
      apiBaseUrl: 'https://api.us.app.phrase.com/api/v2',
      oauthEndpointUrl: "https://api.us.app.phrase.com/api/v2/authorizations",
      profileUrl: "https://us.app.phrase.com/settings/profile",
    }

    βœ… Commits & Pull Requests

    We welcome anyone who wants to contribute to our codebase, so if you notice something, feel free to open a Pull Request! However, we ask that you please use the Conventional Commits specification for your commit messages and titles when opening a Pull Request.

    Example: chore: Update README

    ❓ Issues, Questions, Support

    Please use GitHub issues to share your problem, and we will do our best to answer any questions or to support you in finding a solution.

    πŸ“ Changelog

    Detailed changes for each release are documented in the changelog.