Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/publish-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish NPM package
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org/'
always-auth: true
scope: '@hetznercloud'
- name: ls config
run: npm config ls -l
- name: install dependencies
run: yarn install --frozen-lockfile
- name: build
run: yarn build
- name: publish
run: cd ./dist/ngx-translate-mock && npm publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 4 additions & 1 deletion projects/ngx-translate-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
"name": "@hetznercloud/ngx-translate-mock",
"repository": "https://github.com/hetznercloud/ngx-translate-mock",
"license": "MIT",
"version": "1.0.0",
"version": "1.1.0",
"peerDependencies": {
"@angular/core": ">=14",
"@ngx-translate/core": "^14.0.0",
"rxjs": ">=6"
},
"publishConfig": {
"@hetznercloud:registry": "https://registry.npmjs.org/@hetznercloud"
}
}
21 changes: 16 additions & 5 deletions projects/ngx-translate-mock/src/lib/ngx-translate-mock.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export class TranslateServiceMock {

languages: string[] = ['de'];

get(content: string): Observable<string> {
return of(TRANSLATED_STRING + content);
get(content: string | Array<string>, interpolateParams?: Object): Observable<string | any> {
return typeof content === 'string'
? of(TRANSLATED_STRING + content)
: of(this._translateArray(content));
}

use(lang: string): void {
Expand All @@ -50,11 +52,20 @@ export class TranslateServiceMock {
return of({});
}

instant(key: string | string[], interpolateParams?: object): string {
return TRANSLATED_STRING + key.toString();
}
instant(content: string | Array<string>, interpolateParams?: Object): string | any {
return typeof content === 'string'
? TRANSLATED_STRING + content
: this._translateArray(content);
}

setDefaultLang(lang: string): void {
this.onDefaultLangChangeSubject.next(lang);
}

private _translateArray(content: string[]): Record<string, string> {
return content.reduce((result, item) => {
result[item] = TRANSLATED_STRING + item;
return result;
}, {} as Record<string, string>);
}
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3079,9 +3079,9 @@ debug@^3.2.6:
ms "^2.1.1"

decode-uri-component@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
version "0.2.2"
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==

deep-is@^0.1.3:
version "0.1.4"
Expand Down