Skip to content

Commit

Permalink
fix: translations
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Feb 16, 2024
1 parent d301b04 commit 20d9aa1
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions lib/commands/localization/update.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Command from "#lib/command";
import { ansi } from "#core/text";
import glob from "#core/glob";

export default class extends Command {
static cli () {
Expand All @@ -8,24 +9,41 @@ export default class extends Command {

// public
async run () {
var packages;

// XXX if root not founsd - start from the current dir
// const rootPackage = this._findRootPackage();
const rootPackage = this._findNearestPackage();
const rootPackage = this._findRootPackage();

if ( !rootPackage ) this._throwError( `Unable to find root package` );
if ( rootPackage ) {
packages = [ rootPackage ];
}
else {
const files = glob( "**/*.po" ),
idx = {};

for ( const file of files ) {
const pkg = this._findNearestPackage( file );

if ( !pkg ) continue;

idx[ pkg.root ] = pkg;
}

packages = Object.values( idx );
}

const res = await rootPackage.localization.update();
for ( const pkg of packages ) {
const res = await pkg.localization.update();

if ( !res.ok ) this._exitOnError();
if ( !res.ok ) this._exitOnError();

const localizationStatus = rootPackage.localization.status();
const localizationStatus = rootPackage.localization.status();

if ( localizationStatus.data ) {
console.log( "Localization status:\n" );
if ( localizationStatus.data ) {
console.log( "Localization status:\n" );

for ( const [ poFilePath, isTranslated ] of Object.entries( localizationStatus.data ) ) {
console.log( isTranslated ? " OK " : ansi.error( " FUZZY " ), poFilePath );
for ( const [ poFilePath, isTranslated ] of Object.entries( localizationStatus.data ) ) {
console.log( isTranslated ? " OK " : ansi.error( " FUZZY " ), poFilePath );
}
}
}
}
Expand Down

0 comments on commit 20d9aa1

Please sign in to comment.