Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/i18n #398

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/cmds/app/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports.handler = async yargs => {
await app.build();
process.exit(0);
} catch (err) {
Log.error(err);
Log.error(err.stack);
process.exit(1);
}
};
File renamed without changes.
16 changes: 16 additions & 0 deletions bin/cmds/app/migrate-locales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

const Log = require('../../../lib/Log');
const App = require('../../../lib/App');

exports.desc = 'Migrate all i18n strings from separate files to a single ./homycompose/locales/<language>.json';
exports.handler = async yargs => {
try {
const app = new App(yargs.path);
await app.migrateLocales();
process.exit(0);
} catch (err) {
Log.error(err);
process.exit(1);
}
};
22 changes: 22 additions & 0 deletions lib/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2940,6 +2940,28 @@ $ sudo systemctl restart docker
}
}

async migrateLocales() {
// if (await GitCommands.isGitInstalled() && await GitCommands.isGitRepo({ path: this.path })) {
// if (await this._git.hasUncommittedChanges()) {
// const { shouldContinue } = await inquirer.prompt([
// {
// type: 'confirm',
// name: 'shouldContinue',
// default: false,
// message: 'There are uncommitted changes. Are you sure you want to continue?',
// },
// ]);
// if (!shouldContinue) return;
// }
// }

if (App.hasHomeyCompose({ appPath: this.path }) === false) {
throw new Error('This command requires Homey Compose. Run `homey app migrate-compose` to migrate.');
}

await HomeyCompose.migrateLocales({ appPath: this.path });
}

static hasHomeyCompose({ appPath }) {
const hasComposeFolder = fs.existsSync(path.join(appPath, '.homeycompose'));

Expand Down
Loading
Loading