diff --git a/package.json b/package.json index 7890b90..cfaeb43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@criticalmanufacturing/dev-i18n-transform", - "version": "1.0.6", + "version": "1.0.7", "description": "i18n <--> gettext transform", "main": "src/index.js", "scripts": { diff --git a/src/parsers/typescript.parser.ts b/src/parsers/typescript.parser.ts index af41d51..556d24e 100644 --- a/src/parsers/typescript.parser.ts +++ b/src/parsers/typescript.parser.ts @@ -115,7 +115,7 @@ export class TypescriptParser implements Parser { // Check if the property as any comment associated let symbol = this._typeChecker.getSymbolAtLocation(paNode.name); if (symbol != null) { - messageDescription = ts.displayPartsToString(symbol.getDocumentationComment()); + messageDescription = ts.displayPartsToString(symbol.getDocumentationComment(undefined)); } // Find node bearing diff --git a/src/writers/po.writer.ts b/src/writers/po.writer.ts index 1ab63b7..f1440f1 100644 --- a/src/writers/po.writer.ts +++ b/src/writers/po.writer.ts @@ -52,11 +52,16 @@ msgstr "" // If the translated message is empty or null, try to locate the same message in other files if (!translatedMessage || !translatedMessage.text) { loop: + // Iterate all other files in this package for (const externalFile of this._package.files) { + // In each package, iterate all messages for (const externalMessage of externalFile.messages) { + // Skip itself if (externalFile.uniqueFileName !== currentFile.uniqueFileName || externalMessage.id !== message.id) { + // Get the translation and check if this is the same const externalDefaultMessage = externalMessage.getTranslation(Util.defaultLanguage); - if (externalDefaultMessage.text === defaultMessage.text) { + if (externalDefaultMessage && externalDefaultMessage.text === defaultMessage.text) { + // The default text is the same, so now try to get its translation also const externalTranslatedMessage = externalMessage.getTranslation(this._language); if (externalTranslatedMessage) { translatedMessage = externalTranslatedMessage; diff --git a/test/writers/portableObject.writer.test.ts b/test/writers/portableObject.writer.test.ts index d926a6e..f90ea9c 100644 --- a/test/writers/portableObject.writer.test.ts +++ b/test/writers/portableObject.writer.test.ts @@ -30,7 +30,7 @@ describe("Portable Object writer", () => { const expectedResult = ` # Critical Manufacturing Translation File - # Copyright (C) 2017 Critical Manufacturing S.A. + # Copyright (C) ${new Date().getFullYear()} Critical Manufacturing S.A. # This file is distributed under the GPL 3.0 License # For more information contact@criticalmanufacturing.com # OriginalPackageName: test