Skip to content

Commit

Permalink
Normalize encoding and line endings ^2
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrsatrio committed Jul 9, 2024
1 parent affc348 commit 8c0c7b4
Show file tree
Hide file tree
Showing 32 changed files with 6,835 additions and 6,835 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* text=auto eol=crlf
*.rc text=auto charset=utf-8-sig
*.rc text=auto eol=crlf charset=utf-8-sig
56 changes: 28 additions & 28 deletions .github/workflows/check-files.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
name: Check Files

on:
push:
paths:
- 'resources/lang/*.rc'
pull_request:
paths:
- 'resources/lang/*.rc'

jobs:
check_files:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install chardet

- name: Run file checks
run: node checkFiles.js
name: Check Files

on:
push:
paths:
- 'resources/lang/*.rc'
pull_request:
paths:
- 'resources/lang/*.rc'

jobs:
check_files:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install chardet

- name: Run file checks
run: node checkFiles.js
102 changes: 51 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# ExplorerPatcher-L10N

This repository contains the localization files for [ExplorerPatcher](https://github.com/valinet/ExplorerPatcher). The
base English texts are available in the main repository under:

* Properties Window, Notifications, and Crash
Dialog: [ep_gui/resources/lang](https://github.com/valinet/ExplorerPatcher/tree/master/ep_gui/resources/lang)
* Setup: [ep_setup/resources/lang](https://github.com/valinet/ExplorerPatcher/tree/master/ep_setup/resources/lang)

## Contributing

If you want to have ExplorerPatcher in your language and willing to maintain in the long run, or if you spot a mistake,
an inaccuracy, or want to improve the translations of a language that you are fluent in, pull requests are very much
appreciated.

As we continually update the base English texts, we will add the new keys with English texts to the existing
localization files regardless of the language, for the contributors to translate when possible. This is to keep
ExplorerPatcher working as expected.

It is preferred for translation contributors to be able
to [compile ExplorerPatcher](https://github.com/valinet/ExplorerPatcher/wiki/Compiling) themselves in order to see the
translations in action. If you are not able to do so, please mention it in your pull request and we will test and fix
the translation files for you.

Please make sure that the `.rc` files:
* Are in UTF-8 encoding **with BOM**.
* Have CRLF (`\r\n`) line endings.
* Have double quotes `"` represented as double double quotes `""`.
* Are properly formatted in the same way as the base English texts.

## Acknowledgements

We would like to thank the following people for their contributions in translating ExplorerPatcher:

| Language | Contributor(s) |
|-----------------------|-------------------------------------------------|
| Chinese (Simplified) | @zetaloop, @FrzMtrsprt, @Yukari316 |
| Chinese (Traditional) | @snowlinouo, @Corporation001 |
| Dutch | @GewoonIraj |
| French | @corentios, @Need74 |
| German | @lukinator01, @NotOfficer |
| Hungarian | @RedyAu |
| Indonesian | @Antonomasia, @Amrsatrio |
| Japanese | @creeper-0910, @reindex-ot, @Rukoto, @Amrsatrio |
| Korean | @MuscularPuky |
| Lithuanian | @Kass401 |
| Polish | @BestiaPL |
| Romanian | @21124637 |
| Russian | @the-aLeXiS |
| Turkish | @Akif9748 |
| Ukrainian | @AyzekUorren |
# ExplorerPatcher-L10N

This repository contains the localization files for [ExplorerPatcher](https://github.com/valinet/ExplorerPatcher). The
base English texts are available in the main repository under:

* Properties Window, Notifications, and Crash
Dialog: [ep_gui/resources/lang](https://github.com/valinet/ExplorerPatcher/tree/master/ep_gui/resources/lang)
* Setup: [ep_setup/resources/lang](https://github.com/valinet/ExplorerPatcher/tree/master/ep_setup/resources/lang)

## Contributing

If you want to have ExplorerPatcher in your language and willing to maintain in the long run, or if you spot a mistake,
an inaccuracy, or want to improve the translations of a language that you are fluent in, pull requests are very much
appreciated.

As we continually update the base English texts, we will add the new keys with English texts to the existing
localization files regardless of the language, for the contributors to translate when possible. This is to keep
ExplorerPatcher working as expected.

It is preferred for translation contributors to be able
to [compile ExplorerPatcher](https://github.com/valinet/ExplorerPatcher/wiki/Compiling) themselves in order to see the
translations in action. If you are not able to do so, please mention it in your pull request and we will test and fix
the translation files for you.

Please make sure that the `.rc` files:
* Are in UTF-8 encoding **with BOM**.
* Have CRLF (`\r\n`) line endings.
* Have double quotes `"` represented as double double quotes `""`.
* Are properly formatted in the same way as the base English texts.

## Acknowledgements

We would like to thank the following people for their contributions in translating ExplorerPatcher:

| Language | Contributor(s) |
|-----------------------|-------------------------------------------------|
| Chinese (Simplified) | @zetaloop, @FrzMtrsprt, @Yukari316 |
| Chinese (Traditional) | @snowlinouo, @Corporation001 |
| Dutch | @GewoonIraj |
| French | @corentios, @Need74 |
| German | @lukinator01, @NotOfficer |
| Hungarian | @RedyAu |
| Indonesian | @Antonomasia, @Amrsatrio |
| Japanese | @creeper-0910, @reindex-ot, @Rukoto, @Amrsatrio |
| Korean | @MuscularPuky |
| Lithuanian | @Kass401 |
| Polish | @BestiaPL |
| Romanian | @21124637 |
| Russian | @the-aLeXiS |
| Turkish | @Akif9748 |
| Ukrainian | @AyzekUorren |
122 changes: 61 additions & 61 deletions checkFiles.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
const fs = require('fs');
const path = require('path');
const chardet = require('chardet');

const checkFileEncodingAndLineEndings = (filepath) => {
// Check encoding
const encoding = chardet.detectFileSync(filepath);
if (encoding !== 'UTF-8' && encoding !== 'UTF-8-BOM') {
console.log(`File ${filepath} is not UTF-8 with BOM.`);
return false;
}

// Check for BOM
const fileContent = fs.readFileSync(filepath);
if (!fileContent.slice(0, 3).equals(Buffer.from([0xEF, 0xBB, 0xBF]))) {
console.log(`File ${filepath} does not have BOM.`);
return false;
}

// Check line endings
const content = fileContent.toString('utf8');
if (content.indexOf('\r\n') === -1) {
console.log(`File ${filepath} does not have CRLF line endings.`);
return false;
}

return true;
};

const main = () => {
const baseDir = 'resources/lang';
let allFilesValid = true;

const walkSync = (dir, filelist = []) => {
fs.readdirSync(dir).forEach(file => {
const filepath = path.join(dir, file);
if (fs.statSync(filepath).isDirectory()) {
filelist = walkSync(filepath, filelist);
} else {
filelist.push(filepath);
}
});
return filelist;
};

const rcFiles = walkSync(baseDir).filter(file => file.endsWith('.rc'));

rcFiles.forEach(file => {
if (!checkFileEncodingAndLineEndings(file)) {
allFilesValid = false;
}
});

if (!allFilesValid) {
process.exit(1);
} else {
console.log("All .rc files have the correct encoding and line endings.");
}
};

main();
const fs = require('fs');
const path = require('path');
const chardet = require('chardet');

const checkFileEncodingAndLineEndings = (filepath) => {
// Check encoding
const encoding = chardet.detectFileSync(filepath);
if (encoding !== 'UTF-8' && encoding !== 'UTF-8-BOM') {
console.log(`File ${filepath} is not UTF-8 with BOM.`);
return false;
}

// Check for BOM
const fileContent = fs.readFileSync(filepath);
if (!fileContent.slice(0, 3).equals(Buffer.from([0xEF, 0xBB, 0xBF]))) {
console.log(`File ${filepath} does not have BOM.`);
return false;
}

// Check line endings
const content = fileContent.toString('utf8');
if (content.indexOf('\r\n') === -1) {
console.log(`File ${filepath} does not have CRLF line endings.`);
return false;
}

return true;
};

const main = () => {
const baseDir = 'resources/lang';
let allFilesValid = true;

const walkSync = (dir, filelist = []) => {
fs.readdirSync(dir).forEach(file => {
const filepath = path.join(dir, file);
if (fs.statSync(filepath).isDirectory()) {
filelist = walkSync(filepath, filelist);
} else {
filelist.push(filepath);
}
});
return filelist;
};

const rcFiles = walkSync(baseDir).filter(file => file.endsWith('.rc'));

rcFiles.forEach(file => {
if (!checkFileEncodingAndLineEndings(file)) {
allFilesValid = false;
}
});

if (!allFilesValid) {
process.exit(1);
} else {
console.log("All .rc files have the correct encoding and line endings.");
}
};

main();
Loading

0 comments on commit 8c0c7b4

Please sign in to comment.