diff --git a/.bitmap b/.bitmap deleted file mode 100644 index 08c49601..00000000 --- a/.bitmap +++ /dev/null @@ -1,25 +0,0 @@ -/* THIS IS A BIT-AUTO-GENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. */ - -/** - * The Bitmap file is an auto generated file used by Bit to track all your Bit components. It maps the component to a folder in your file system. - * This file should be committed to VCS(version control). - * Components are listed using their component ID (https://bit.dev/docs/components/component-id). - * If you want to delete components you can use the "bit remove " command. - * See the docs (https://bit.dev/docs/components/removing-components) for more information, or use "bit remove --help". - */ - -{ - "core": { - "scope": "ngx-translate.packages", - "version": "15.0.0", - "mainFile": "public-api.ts", - "rootDir": "packages/core" - }, - "http-loader": { - "scope": "ngx-translate.packages", - "version": "8.0.0", - "mainFile": "public-api.ts", - "rootDir": "packages/http-loader" - }, - "$schema-version": "15.0.0" -} \ No newline at end of file diff --git a/.editorconfig b/.editorconfig index 3b7ad774..6e87a003 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,12 +1,10 @@ -# editorconfig.org - +# Editor configuration, see http://editorconfig.org root = true [*] charset = utf-8 -end_of_line = lf -indent_size = 2 indent_style = space +indent_size = 2 insert_final_newline = true trim_trailing_whitespace = true diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 3c3629e6..00000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 9c3f23aa..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = { - parser: '@typescript-eslint/parser', - root: true, - ignorePatterns: ['node_modules'], - parserOptions: { - createDefaultProgram: true, - }, - env: { - browser: true, - node: true, - es6: true, - jest: true, - }, - overrides: [ - { - files: ['*.ts', '*.js'], - parserOptions: { - project: require.resolve('./tsconfig.json'), - createDefaultProgram: true, - }, - extends: ['plugin:@angular-eslint/recommended', 'plugin:@angular-eslint/template/process-inline-templates'], - }, - { - files: ['*.html'], - extends: ['plugin:@angular-eslint/template/recommended'], - }, - { - files: ['*.md'], - extends: ['plugin:markdown/recommended'], - }, - ], -}; diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 67628bc7..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: CI - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [ master ] - pull_request: - branches: [ master ] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -env: - BIT_TOKEN: ${{ secrets.BIT_TOKEN }} - -jobs: - # Test angular - default-angular: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, 'skip-ci')" - container: - image: docker://bitcli/bit:latest-node-16.15.0 - steps: - - uses: teambit/setup-action@v2.02 - with: - name: angular-github-actions - BIT_TOKEN: ${{ env.BIT_TOKEN }} - - - uses: actions/checkout@v2 - - - name: Install dependencies - run: bit install --log error - - - name: Bit test - run: bit test --log error - - - name: Bit lint - run: bit lint --log error - - - name: Bit status - run: bit status --log error - - - name: Bit build core - run: bit build core --log error - - - name: Bit build http-loader - run: bit build http-loader --skip-tests --log error - - - uses: actions/upload-artifact@v2 - with: - name: debug-log - path: $HOME/Library/Caches/Bit/logs diff --git a/.github/workflows/ngx-translate-test.yml b/.github/workflows/ngx-translate-test.yml new file mode 100644 index 00000000..7ca9d375 --- /dev/null +++ b/.github/workflows/ngx-translate-test.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + push: + branches: [ "*" ] + pull_request: + branches: [ "*" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm run build-all + - run: npm run test-ci diff --git a/.gitignore b/.gitignore index 96862efd..b08ee346 100644 --- a/.gitignore +++ b/.gitignore @@ -1,112 +1,43 @@ -# Bit -.bit -public - -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn -.yarn-integrity -.yarn - -# dotenv environment variables file -.env -.env.test - -# parcel-bundler cache (https://parceljs.org/) -.cache - -# Next.js build output -.next - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -.history - -# IDEs -.vscode -.idea/ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp +/out-tsc +/.angular + +# dependencies +/node_modules + +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +yarn-error.log +testem.log +/typings + +# System Files +.DS_Store +Thumbs.db + +packages/core/.idea +packages/http-loader/.idea diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 9f059216..00000000 --- a/.prettierrc.js +++ /dev/null @@ -1,6 +0,0 @@ -{ - "tabWidth": 2, - "printWidth": 120, - "parser": "typescript", - "singleQuote": true -} diff --git a/LICENSE b/LICENSE index 06e2ab30..59f808db 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ -Copyright (c) 2023 Olivier Combe +Copyright (c) 2018 Olivier Combe +Copyright (c) 2024 Andreas Löw / CodeAndWeb GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 62f07291..2da60138 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,75 @@ -# @ngx-translate/core ![Build Status](https://github.com/ngx-translate/core/actions/workflows/main.yml/badge.svg) [![npm version](https://badge.fury.io/js/%40ngx-translate%2Fcore.svg)](https://badge.fury.io/js/%40ngx-translate%2Fcore) +# @ngx-translate/core ![Buildstatus](https://github.com/ngx-translate/core/actions/workflows/ngx-translate-test.yml/badge.svg) [![npm version](https://badge.fury.io/js/%40ngx-translate%2Fcore.svg)](https://badge.fury.io/js/%40ngx-translate%2Fcore) The internationalization (i18n) library for Angular. +
-Simple example using ngx-translate: https://stackblitz.com/github/ngx-translate/example +## Angular 16, 17, 18+ -Get the complete changelog here: https://github.com/ngx-translate/core/releases +The [new documentation](https://ngx-translate.org/) now covers installation on +Angular 16+ and is divided into smaller, more readable sections, making it +easier to digest than this big README. It also documents the additional +interfaces and explains how to develop custom plugins. -## Table of Contents +New documentation: **https://ngx-translate.org/** + +In addition to that, a getting started tutorial is available here: +[How to Translate Your Angular App with NGX-Translate](https://www.codeandweb.com/babeledit/tutorials/how-to-translate-your-angular-app-with-ngx-translate) + +This [Demo project](https://github.com/CodeAndWeb/ngx-translate-demo) +contains 3 simple example projects for Standalone components, NgModules, and +how to use the message format compiler. The branches contain the same +projects for older Angular versions. + +The complete changelog of ngx-translate: https://github.com/ngx-translate/core/releases + +
+
+
+
+
+
+ +## Angular <=15 + +This documentation is still available for **older versions of Angular**. Newer +versions of Angular use Standalone Components by default, which are not +explained here. + +Simple example using ngx-translate: +https://stackblitz.com/github/ngx-translate/example + +### Table of Contents * [Installation](#installation) * [Usage](#usage) - * [Import the TranslateModule](#1-import-the-translatemodule) - * [SharedModule](#sharedmodule) - * [Lazy loaded modules](#lazy-loaded-modules) - * [Configuration](#configuration) - * [AoT](#aot) - * [Define the default language for the application](#2-define-the-default-language-for-the-application) - * [Init the TranslateService for your application](#3-init-the-translateservice-for-your-application) - * [Define the translations](#4-define-the-translations) - * [Use the service, the pipe or the directive](#5-use-the-service-the-pipe-or-the-directive) - * [Use HTML tags](#6-use-html-tags) + * [Import the TranslateModule](#1-import-the-translatemodule) + * [SharedModule](#sharedmodule) + * [Lazy loaded modules](#lazy-loaded-modules) + * [Configuration](#configuration) + * [AoT](#aot) + * [Define the default language for the application](#2-define-the-default-language-for-the-application) + * [Init the TranslateService for your application](#3-init-the-translateservice-for-your-application) + * [Define the translations](#4-define-the-translations) + * [Use the service, the pipe or the directive](#5-use-the-service-the-pipe-or-the-directive) + * [Use HTML tags](#6-use-html-tags) * [API](#api) - * [TranslateService](#translateservice) - * [Properties](#properties) - * [Methods](#methods) - * [Write & use your own loader](#write--use-your-own-loader) - * [Example](#example) - * [How to use a compiler to preprocess translation values](#how-to-use-a-compiler-to-preprocess-translation-values) - * [How to handle missing translations](#how-to-handle-missing-translations) - * [Example](#example-1) - * [Parser](#parser) - * [Methods](#methods) + * [TranslateService](#translateservice) + * [Properties](#properties) + * [Methods](#methods) + * [Write & use your own loader](#write--use-your-own-loader) + * [Example](#example) + * [How to use a compiler to preprocess translation values](#how-to-use-a-compiler-to-preprocess-translation-values) + * [How to handle missing translations](#how-to-handle-missing-translations) + * [Example](#example-1) + * [Parser](#parser) + * [Methods](#methods) * [FAQ](#faq) - * [I'm getting an error `npm ERR! peerinvalid Peer [...]`](#im-getting-an-error-npm-err-peerinvalid-peer-) + * [I'm getting an error `npm ERR! peerinvalid Peer [...]`](#im-getting-an-error-npm-err-peerinvalid-peer-) * [Plugins](#plugins) * [Editors](#editors) * [Additional Framework Support](#additional-framework-support) -## Installation +### Installation First you need to install the npm module: @@ -61,7 +93,7 @@ Choose the version corresponding to your Angular version: 2 to 4.2.x | 7.x or less | 0.x -## Usage +### Usage #### 1. Import the `TranslateModule`: @@ -302,8 +334,8 @@ param = {value: 'world'}; You can construct the translation keys dynamically by using simple string concatenation inside the template: ```html -