Skip to content

Commit f7b429c

Browse files
committed
Initial Commit
1 parent 22dd987 commit f7b429c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+13715
-3
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build and Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build-and-deploy:
12+
concurrency: ci-${{ github.ref }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout 🛎️
16+
uses: actions/checkout@v3
17+
18+
- name: Install and Build 🔧
19+
run: |
20+
npm ci
21+
npm run build
22+
23+
- name: Deploy 🚀
24+
uses: JamesIves/github-pages-deploy-action@v4
25+
with:
26+
folder: dist/angular-intl-demo

.gitignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db

.vscode/extensions.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3+
"recommendations": [
4+
"angular.ng-template"
5+
]
6+
}

.vscode/launch.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"name": "ng serve",
7+
"type": "pwa-chrome",
8+
"request": "launch",
9+
"preLaunchTask": "npm: start",
10+
"url": "http://localhost:4200/"
11+
},
12+
{
13+
"name": "ng test",
14+
"type": "chrome",
15+
"request": "launch",
16+
"preLaunchTask": "npm: test",
17+
"url": "http://localhost:9876/debug.html"
18+
}
19+
]
20+
}

.vscode/tasks.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3+
"version": "2.0.0",
4+
"tasks": [
5+
{
6+
"type": "npm",
7+
"script": "start",
8+
"isBackground": true,
9+
"problemMatcher": {
10+
"owner": "typescript",
11+
"pattern": "$tsc",
12+
"background": {
13+
"activeOnStart": true,
14+
"beginsPattern": {
15+
"regexp": "(.*?)"
16+
},
17+
"endsPattern": {
18+
"regexp": "bundle generation complete"
19+
}
20+
}
21+
}
22+
},
23+
{
24+
"type": "npm",
25+
"script": "test",
26+
"isBackground": true,
27+
"problemMatcher": {
28+
"owner": "typescript",
29+
"pattern": "$tsc",
30+
"background": {
31+
"activeOnStart": true,
32+
"beginsPattern": {
33+
"regexp": "(.*?)"
34+
},
35+
"endsPattern": {
36+
"regexp": "bundle generation complete"
37+
}
38+
}
39+
}
40+
}
41+
]
42+
}

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Daniel
3+
Copyright (c) 2023 Daniel Kimmich
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+87-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,87 @@
1-
# angular-ecmascript-intl
2-
Contains pipes to transform internationalization data using `Intl.*` browser APIs
1+
# Angular ECMAScript Intl
2+
3+
Contains pipes to transform internationalization data using `Intl.*` browser APIs.
4+
5+
## Getting started
6+
7+
Install the package:
8+
9+
```
10+
npm install angular-ecmascript-intl --save
11+
```
12+
13+
Import the `IntlModule`:
14+
15+
```typescript
16+
import { NgModule } from '@angular/core';
17+
import { IntlModule } from 'angular-ecmascript-intl';
18+
19+
@NgModule({
20+
imports: [
21+
IntlModule,
22+
],
23+
})
24+
export class MyModule {
25+
}
26+
```
27+
28+
By default, the pipe will use the browser default locale. If you want to override it, you can provide the `INTL_LOCALES`
29+
injection token:
30+
31+
```
32+
import { NgModule } from '@angular/core';
33+
import { INTL_LOCALES } from 'angular-ecmascript-intl';
34+
35+
@NgModule({
36+
providers: [
37+
{
38+
provide: INTL_LOCALES,
39+
useValue: 'de-DE',
40+
},
41+
],
42+
})
43+
export class MyModule {
44+
}
45+
```
46+
47+
Now you can use the pipes, see below.
48+
49+
## Pipes
50+
51+
### Date Pipe
52+
53+
Use the date pipe like the following:
54+
55+
```
56+
{{myDate | intlDate: options}}
57+
```
58+
59+
The input date can be one of the following:
60+
61+
* `Date` object
62+
* number (UNIX timestamp)
63+
* string (will be parsed by `new Date()` constructor)
64+
* null
65+
* undefined
66+
67+
The options are the same as the options for `new Intl.DateTimeFormat()`. For a list of the options, see
68+
their [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).
69+
70+
With the `INTL_DATE_PIPE_DEFAULT_OPTIONS` injection token you can specify default options.
71+
72+
## Background
73+
74+
Working with Angular's built-in pipes which support internationalization works fine when only supporting one locale.
75+
But nowadays, you want to support many locales, to give every user a good user experience. To get this working with
76+
Angular's built-in pipes can be time-consuming, because data for every locale must be included
77+
to the application. This increases bundle size and load times.
78+
79+
Modern browsers are fully capable of handling internationalization with the `Intl.*` browser APIs. There is no need for
80+
loading any locale date. This package re-implements some Angular built-in pipes such as `date` using these APIs.
81+
82+
## Roadmap
83+
84+
* Language pipe
85+
* Country pipe
86+
* Number pipe(s)
87+
* Relative time

angular.json

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"angular-ecmascript-intl": {
7+
"projectType": "library",
8+
"root": "projects/angular-ecmascript-intl",
9+
"sourceRoot": "projects/angular-ecmascript-intl/src",
10+
"prefix": "intl",
11+
"architect": {
12+
"build": {
13+
"builder": "@angular-devkit/build-angular:ng-packagr",
14+
"options": {
15+
"project": "projects/angular-ecmascript-intl/ng-package.json"
16+
},
17+
"configurations": {
18+
"production": {
19+
"tsConfig": "projects/angular-ecmascript-intl/tsconfig.lib.prod.json"
20+
},
21+
"development": {
22+
"tsConfig": "projects/angular-ecmascript-intl/tsconfig.lib.json"
23+
}
24+
},
25+
"defaultConfiguration": "production"
26+
},
27+
"test": {
28+
"builder": "@angular-devkit/build-angular:karma",
29+
"options": {
30+
"tsConfig": "projects/angular-ecmascript-intl/tsconfig.spec.json",
31+
"polyfills": [
32+
"zone.js",
33+
"zone.js/testing"
34+
]
35+
}
36+
}
37+
}
38+
},
39+
"angular-intl-demo": {
40+
"projectType": "application",
41+
"schematics": {
42+
"@schematics/angular:component": {
43+
"style": "scss"
44+
}
45+
},
46+
"root": "projects/angular-intl-demo",
47+
"sourceRoot": "projects/angular-intl-demo/src",
48+
"prefix": "app",
49+
"architect": {
50+
"build": {
51+
"builder": "@angular-devkit/build-angular:browser",
52+
"options": {
53+
"outputPath": "dist/angular-intl-demo",
54+
"index": "projects/angular-intl-demo/src/index.html",
55+
"main": "projects/angular-intl-demo/src/main.ts",
56+
"polyfills": [
57+
"zone.js"
58+
],
59+
"tsConfig": "projects/angular-intl-demo/tsconfig.app.json",
60+
"inlineStyleLanguage": "scss",
61+
"assets": [
62+
"projects/angular-intl-demo/src/favicon.ico",
63+
"projects/angular-intl-demo/src/assets"
64+
],
65+
"styles": [
66+
"@angular/material/prebuilt-themes/deeppurple-amber.css",
67+
"projects/angular-intl-demo/src/styles.scss"
68+
],
69+
"scripts": []
70+
},
71+
"configurations": {
72+
"production": {
73+
"budgets": [
74+
{
75+
"type": "initial",
76+
"maximumWarning": "500kb",
77+
"maximumError": "1mb"
78+
},
79+
{
80+
"type": "anyComponentStyle",
81+
"maximumWarning": "2kb",
82+
"maximumError": "4kb"
83+
}
84+
],
85+
"outputHashing": "all"
86+
},
87+
"development": {
88+
"buildOptimizer": false,
89+
"optimization": false,
90+
"vendorChunk": true,
91+
"extractLicenses": false,
92+
"sourceMap": true,
93+
"namedChunks": true
94+
}
95+
},
96+
"defaultConfiguration": "production"
97+
},
98+
"serve": {
99+
"builder": "@angular-devkit/build-angular:dev-server",
100+
"configurations": {
101+
"production": {
102+
"browserTarget": "angular-intl-demo:build:production"
103+
},
104+
"development": {
105+
"browserTarget": "angular-intl-demo:build:development"
106+
}
107+
},
108+
"defaultConfiguration": "development"
109+
},
110+
"extract-i18n": {
111+
"builder": "@angular-devkit/build-angular:extract-i18n",
112+
"options": {
113+
"browserTarget": "angular-intl-demo:build"
114+
}
115+
},
116+
"test": {
117+
"builder": "@angular-devkit/build-angular:karma",
118+
"options": {
119+
"polyfills": [
120+
"zone.js",
121+
"zone.js/testing"
122+
],
123+
"tsConfig": "projects/angular-intl-demo/tsconfig.spec.json",
124+
"inlineStyleLanguage": "scss",
125+
"assets": [
126+
"projects/angular-intl-demo/src/favicon.ico",
127+
"projects/angular-intl-demo/src/assets"
128+
],
129+
"styles": [
130+
"@angular/material/prebuilt-themes/deeppurple-amber.css",
131+
"projects/angular-intl-demo/src/styles.scss"
132+
],
133+
"scripts": []
134+
}
135+
}
136+
}
137+
}
138+
}
139+
}

0 commit comments

Comments
 (0)