-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1572 from sora-xor/release/1.42.0
Release 1.42.0
- Loading branch information
Showing
43 changed files
with
2,326 additions
and
5,147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import fs from 'fs'; | ||
|
||
import { format, sortAlpha } from './utils'; | ||
|
||
(async function main() { | ||
const buildDir = './src/lang'; | ||
if (!fs.existsSync(buildDir)) { | ||
fs.mkdirSync(buildDir); | ||
} | ||
const langObj = (await import('../../src/lang/en.json')).default; | ||
const formatted = format(langObj); | ||
const sorted = sortAlpha(formatted); | ||
fs.writeFileSync(`${buildDir}/en.json`, JSON.stringify(sorted, null, 4)); | ||
console.info(`${buildDir}/en.json fixed!`); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export function format(obj: any) { | ||
if (typeof obj !== 'object' || obj === null) return obj; | ||
|
||
const keys = Object.keys(obj); | ||
|
||
if (!keys.length) return null; | ||
|
||
const formatted = {}; | ||
|
||
keys.forEach((key) => { | ||
const inner = format(obj[key]); | ||
if (inner) { | ||
formatted[key] = inner; | ||
} | ||
}); | ||
|
||
return formatted; | ||
} | ||
|
||
export function sortAlpha(obj: any) { | ||
if (typeof obj !== 'object') return obj; | ||
|
||
const sorted = {}; | ||
|
||
const keys = Object.keys(obj) | ||
.map((k) => [k, k.toLowerCase()]) | ||
.sort((a, b) => a[1].localeCompare(b[1])) | ||
.map(([k]) => k); | ||
|
||
keys.forEach((key) => { | ||
sorted[key] = sortAlpha(obj[key]); | ||
}); | ||
|
||
return sorted; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.