Skip to content

Commit

Permalink
feat: implement initial version (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation committed Jan 1, 2020
1 parent 634340e commit 1b5502c
Show file tree
Hide file tree
Showing 145 changed files with 23,492 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
52 changes: 52 additions & 0 deletions .github/workflow/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Continuous Integration
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Shallow checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12

- name: Restore dependencies from cache
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

lint:
runs-on: ubuntu-latest
needs: build
steps:
- name: Shallow checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12

- name: Restore dependencies from cache
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci

- name: Build package
run: npm run lint
37 changes: 37 additions & 0 deletions .github/workflow/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Shallow checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'

- name: Restore dependencies from cache
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Publish package
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json

# 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
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
schematics/**/*.js
schematics/**/*.map
schematics/**/*.d.ts
builders/**/*.js
builders/**/*.map
builders/**/*.d.ts

# System Files
.DS_Store
Thumbs.db
14 changes: 14 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.github/*
browserslist
LICENSE
coverage
dist
package-lock.json
.*
*.ico
*.xlf
*.svg
builders/*/index.js
builders/*/index.d.ts
schematics/*/index.js
schematics/*/index.d.ts
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
# translation-webapp
# angular-t9n

This project is a tool to manage `.xlf` translation files. It is implemented as an Angular builder and can be added to a project via schematics.

`angular-t9n` allows adding translation targets, editing translations, exporting to Excel, importing from Excel and migrating orphaned translations.

## Installation

```
ng add angular-t9n
```

This will add a `t9n` section to the architect section of your `angular.json`.

## Configuration

The following properties can be configured in the `t9n` section in the `angular.json` file.

| Property | Description |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| translationFile | The file path to the source translation file.<br>**Default: message.xlf** |
| targetTranslationPath | The path to the target translation files.<br>**Default: dirname(translationFile)** |
| includeContextInTarget | Whether to include the context information<br>(like notes) in the target files. This is<br>useful for sending the target translation<br>files to translation agencies/services.<br>**Default: false** |
| encoding | The encoding of the translation files.<br>**Default: UTF-8** |
| port | The port on which to host the translation app.<br>Default: **4300** |

## Usage

Run `ng run {projectName}:t9n`, where `{projectName}` is the name of the project in the `angular.json` file, to start the translation app and open your browser at [http://localhost:4300/](http://localhost:4300/).
132 changes: 132 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-t9n": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "t9n",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"aot": true,
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "angular-t9n:build"
},
"configurations": {
"production": {
"browserTarget": "angular-t9n:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular-t9n:build",
"format": "xlf2",
"i18nLocale": "en",
"outputPath": "locale/xlf2"
},
"configurations": {
"xlf": {
"format": "xlf",
"outputPath": "locale/xlf"
}
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": [],
"assets": ["src/favicon.ico", "src/assets"]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"t9n": {
"builder": ".:t9n",
"options": {
"translationFile": "src/locale/xlf2/messages.xlf",
"includeContextInTarget": true
},
"configurations": {
"xlf": {
"translationFile": "src/locale/xlf/messages.xlf",
"includeContextInTarget": true
}
}
}
}
}
},
"defaultProject": "angular-t9n",
"cli": {
"analytics": "8b634d96-e479-4c86-941f-7a18382b3c88"
}
}
28 changes: 28 additions & 0 deletions brotlify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { readdir, readFile, writeFile } = require('fs');
const { join } = require('path');
const { promisify } = require('util');
const { brotliCompress, constants } = require('zlib');

const readdirAsync = promisify(readdir);
const readFileAsync = promisify(readFile);
const writeFileAsync = promisify(writeFile);
const brotliCompressAsync = promisify(brotliCompress);

(async () => {
const directory = join(__dirname, 'dist');
const files = await readdirAsync(directory, { withFileTypes: true });
const compressions = files
.filter(f => f.isFile() && ['html', 'js', 'css'].some(e => f.name.endsWith(`.${e}`)))
.map(f => join(directory, f.name))
.map(async f => {
const content = await readFileAsync(f, 'utf8');
const compressedContent = await brotliCompressAsync(content, {
params: {
[constants.BROTLI_PARAM_QUALITY]: constants.BROTLI_MAX_QUALITY
}
});
await writeFileAsync(`${f}.br`, compressedContent);
console.log(`Brotlified ${f}`);
});
await Promise.all(compressions);
})();
11 changes: 11 additions & 0 deletions browserslist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed

> 0.5%
last 2 versions
Firefox ESR
not dead
IE 11
9 changes: 9 additions & 0 deletions builders/builders.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"builders": {
"t9n": {
"implementation": "./t9n",
"schema": "./t9n/schema.json",
"description": "Translation server for Angular."
}
}
}
Loading

0 comments on commit 1b5502c

Please sign in to comment.