Skip to content

Commit

Permalink
refactor(i18n): replace i18n package translator with custom translator
Browse files Browse the repository at this point in the history
  • Loading branch information
simplymichael committed Jan 11, 2021
1 parent 1dc6b9b commit bd4e99d
Show file tree
Hide file tree
Showing 11 changed files with 360 additions and 323 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ build
.markdown-viewer
_test-directory
_steps.md
.localeEx
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ _tests/
.travis.yml
.nyc_output/
.markdown-viewer
.localeEx
_test-directory
136 changes: 136 additions & 0 deletions locales/en/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"answers": {
"alreadyHave": "already have",
"no": "no",
"none": "None",
"other": "Other",
"unlicensed": "Unlicensed",
"yes": "yes"
},
"info": {
"promptNotSupported": "Prompt cannot be rendered in the current environment",
"somethingWrong": "Something has gone wrong"
},
"questions": {
"projectDesc": "description",
"createSrcDir": "Create source directory",
"specifySrcDir": "Specify your source directory",
"linter": "Linter",
"dependencies": "Dependencies, separated by spaces or commas: (dep@version dep2 dep3@version)",
"devDependencies": "Dev dependencies, separated by spaces or commas: (dep@version dep2 dep3@version)",
"github": {
"configName": "Your name (git config user.name value)",
"username": "Github username",
"email": "Github email",
"validEmailPrompt": "Please enter a valid email",
"url": "Github project URL"
},
"license": {
"titler": "License",
"owner": "License Owner/Organization name",
"year": "License Year"
},
"tests": {
"framework": "Choose a test framework",
"createDir": "Create test directory",
"specifyDir": "Specify your test directory",
"directory": "Test directory",
"filesExt": "Test files extension",
"unlistedFilesExt": "Specify your test files extension"
},
"choices": {
"project": {
"header": "Project",
"name": "name",
"description": "description",
"directory": "directory",
"owner": "owner"
},
"github": {
"header": "GitHub",
"username": "username",
"email": "email",
"url": "url"
},
"license": {
"header": "License",
"owner": "owner",
"name": "name",
"year": "year"
},
"tests": {
"header": "Test",
"framework": "framework",
"extension": "extension",
"directory": "directory"
},
"linter": "Linter",
"dependencies": "Dependencies",
"devDependencies": "Dev dependencies",
"srcDir": "Source directory",
"review": "Please review selection",
"proceed": "Proceed?"
}
},
"setup": {
"creating": "Creating",
"created": "created",
"delayedOp": "This might take a while",
"installing": "Installing",
"installed": "installed",
"git": {
"initializing": "Initializing git...",
"initialized": "Initialized empty git repository",
"isRepo": "The specified directory is a git repository...",
"isSkipping": "Skipping \"git init\"'",
"creatingIgnoreFile": "Creating .gitignore file...",
"ignoreFileCreated": ".gitignore file created"
},
"npm": {
"initializing": "Creating package.json...",
"initialized": "package.json created",
"hasPackageJson": "The specified directory already contains a package.json file...",
"isSkipping": "skipping \"npm init\"",
"installingDeps": "Installing dependencies",
"installingDevDeps": "Installing dev dependencies",
"depsInstalled": "Dependencies installed",
"devDepsInstalled": "Dev dependencies installed",
"updating": "Updating package.json",
"updated": "package.json updated"
},
"tests": {
"settingUp": "Setting up tests",
"setupComplete": "Tests setup complete",
"creatingSamples": "Creating sample test files...",
"samplesCreated": "Sample test files created",
"shouldPass": "should pass",
"helloWorld": "Hello world!"
},
"directories": {
"creatingSrcDir": "Creating source directory",
"srcDirCreated": "Source directory created",
"creatingTestDir": "Creating test directory",
"testDirCreated": "Test directory created"
},
"files": {
"creatingReadme": "Creating README file",
"readmeCreated": "README file created",
"generatingLicense": "Generating license",
"licenseGenerated": "License generated"
},
"finalize": {
"almostDone": "You are almost done",
"setupEslint": "Please take a moment to setup ESLint.",
"lintingErrors": "There appears to be some linting errors.",
"checkLintingErrors": "Run \"npm run lint\" to check them",
"allSet": "You are all set",
"runTests": "To run your tests, run",
"runCoverage": "To run tests with coverage reporting, run",
"commit": "To commit your changes, run",
"fixLintingErrors": "To fix linting errors, run",
"firstRelease": "To run your first release, run",
"subsequentRelease": "To run subsequent releases, run",
"releaseDryRun": "To run release dry-run, run"
}
}
}
8 changes: 8 additions & 0 deletions locales/en/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"short": "en",
"long": "English",
"creator": {
"username": "simplymichael",
"url": "https://github.com/simplymichael"
}
}
17 changes: 17 additions & 0 deletions locales/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs');
const path = require('path');
const languages = {};
const files = fs.readdirSync(__dirname);

for(let i = 0, len = files.length; i < len; i++) {
const filename = path.basename(files[i], '.js');

// don't iclude this index.js file
if(filename === 'index') {
continue;
}

languages[filename] = require(`./${filename}`);
}

module.exports = languages;
90 changes: 6 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"commander": "6.2.1",
"email-validator": "2.0.4",
"empty-dir": "2.0.0",
"i18n": "^0.13.2",
"inquirer": "7.3.3",
"kleur": "4.1.3",
"lice": "1.1.0",
Expand Down
9 changes: 0 additions & 9 deletions src/i18n.js

This file was deleted.

Loading

0 comments on commit bd4e99d

Please sign in to comment.