Skip to content

Commit

Permalink
feat: Create parse-langtags utility to convert langtags.json (#24)
Browse files Browse the repository at this point in the history
* feat: Create parse-langtags utility to convert langtags.json

* revert DoulosSILR.ttf font

* fix: parse-langtags to handle edge cases

* Remove `|` from language name because it's a delimiter character
* Handle `XK` as industry region for "Kosovo"
* Handle registered `valencia`subtag
* Ignore `x-bad-mru-Cyrl-RU`

* fix: Rewrite how iso639.txt is converted to codes

* chore: Update readme info

* chore: Clean up typo and whitespace
  • Loading branch information
darcywong00 authored Aug 13, 2021
1 parent 5b5eba4 commit 6c98eb3
Show file tree
Hide file tree
Showing 16 changed files with 11,721 additions and 537 deletions.
3 changes: 2 additions & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ To build Speech Analyzer, do the following:
1. Use *Ctrl-Alt-F7* or select *Build/Rebuild Solution* from the menu to build the project.
1. Wait for the build to complete. You will see the following in the *Build Output* window then the project is done compiling: *Rebuild All: 15 succeeded, 0 failed, 0 skipped*
1. Depending on the build configuration you selected, *Debug* or *Release*, Visual Studio will create either a *Debug* or *Release* directory at the root of the project. (e.g. SpeechAnalyzer/Debug*).
1. Copy DistFiles\iso639.txt into the *Debug* or *Release* directory. You will only need to do this once.
1. Copy DistFiles\iso639.txt into the *Debug* or *Release* directory. You will only need to do this once.
Refer to [README.md](DevUtils\parse-langtags\README.md) if you need to re-generate iso639.txt.
1. Start SpeechAnalyzer by right-clicking on the *SA* project and selecting *Debug/Start new instance*.

# Installer Creation
Expand Down
12 changes: 12 additions & 0 deletions DevUtils/parse-langtags/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Editor configuration, see https://editorconfig.org
root = true

[*.{js,ts}]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
7 changes: 7 additions & 0 deletions DevUtils/parse-langtags/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Dependencies
node_modules

langtags.json

# Compiled Output files
dist/
21 changes: 21 additions & 0 deletions DevUtils/parse-langtags/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Program",
"sourceMaps": true,
"program": "${workspaceFolder}/dist/index.js",
"outFiles": [
"${workspaceFolder}/dist/**.js"
],
"args": [
"-o", "iso639.txt"
]
}
]
}
16 changes: 16 additions & 0 deletions DevUtils/parse-langtags/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
21 changes: 21 additions & 0 deletions DevUtils/parse-langtags/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 SIL International

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:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
77 changes: 77 additions & 0 deletions DevUtils/parse-langtags/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

# parse-langtags
Utility to convert [langtags.json](https://github.com/silnrsi/langtags) into a language list for Speech Analyzer.

## Usage
Command-line:
```bash
node dist/index.js
-o [output file]
```

Typically, use `iso639.txt` for the output file name.

-----

### Get the latest langtags.json file
This will download the latest copy of langtags.json into this current folder

`npm run get`

----

### Convert langtags.json
1. Compile the project
`npm run build`
2. Convert langtags.json into an output file (e.g. iso639.txt)
`node dist/index.js -o iso639.txt`
------------------


## Developer Setup
This utility requires Git, Node.js, and TypeScript (installed locally).

### Install Git
Download and install Git

https://git-scm.com/downloads

### Install Node.js and Dependencies
Download and install the latest current version for Node.js (>=14.15.0)

https://nodejs.org/en/download/current/

After installing Node.js, reboot your PC, open Git Bash to this directory and install this project's dependencies:
```bash
npm install
```

This will install [TypeScript](https://www.typescriptlang.org/) locally and can be accessed with

```bash
npx tsc
```

### Compiling parse-langs
This compiles the TypeScript source files in `src/` into Javascript (`dist/`)

To rebuild the project
```bash
npm run build
```

You can also have TypeScript watch the project and recompile automatically
```bash
npm run watch
```

### Debugging with Visual Studio Code
Open Folder as a VS Code Project

Edit your applicable parameters in [launch.json](./.vscode/launch.json). If using Windows paths, you'll need to escape the slashes (e.g. `-p "C:\\somewhere\\to\\iso639.txt"`)

-------------

## License for parse-langtags
Copyright (c) 2021 SIL International. All rights reserved.
Licensed under the [MIT license](LICENSE).
Loading

0 comments on commit 6c98eb3

Please sign in to comment.