Skip to content

Commit

Permalink
fix: translations
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Feb 17, 2024
1 parent aeccc63 commit 2954bc0
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/get-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ export default class GetText {

#parseYaml ( content ) {
const locale = {
"l10n": ( single, plural, pluralNumber ) => {
if ( single ) {
"l10n": ( singular, plural, pluralNumber ) => {
if ( singular ) {
this.#poFile.addEctractedMessages( {
[ single ]: {
[ singular ]: {
"references": [ this.#relativePath ],
},
} );
Expand All @@ -155,10 +155,10 @@ export default class GetText {
}
},

"l10nt": ( single, plural, pluralNumber ) => {
if ( single ) {
"l10nt": ( singular, plural, pluralNumber ) => {
if ( singular ) {
this.#poFile.addEctractedMessages( {
[ single ]: {
[ singular ]: {
"references": [ this.#relativePath ],
},
} );
Expand Down Expand Up @@ -255,7 +255,7 @@ export default class GetText {
// not a supported function / method name
if ( method !== "l10n" && method !== "l10nt" ) return;

var single = {
const singular = {
"id": null,
"flags": null,
"references": null,
Expand All @@ -273,13 +273,13 @@ export default class GetText {
} );

if ( message.value ) {
single.id = message.value;
singular.id = message.value;

if ( message.isTemplate ) single.flags = [ "javascript-format" ];
if ( message.isTemplate ) singular.flags = [ "javascript-format" ];

// references
const { line, column } = this.#getNodeLocation( node.arguments[ 0 ], { start } );
single.references = [ `${ this.#relativePath }:${ line }:${ column }` ];
singular.references = [ `${ this.#relativePath }:${ line }:${ column }` ];
}

// plural
Expand All @@ -300,15 +300,15 @@ export default class GetText {
}
}

if ( !single.id && !plural.id ) return;
if ( !singular.id && !plural.id ) return;

// extracted comments
const extractedComments = this.#extractNodeComment( ast, node );

if ( single.id ) {
if ( singular.id ) {
this.#poFile.addEctractedMessages( {
[ single.id ]: {
...single,
[ singular.id ]: {
...singular,
extractedComments,
},
} );
Expand Down

0 comments on commit 2954bc0

Please sign in to comment.