Skip to content

Commit

Permalink
Merge pull request #8 from criticalmanufacturing/master-translation-n…
Browse files Browse the repository at this point in the history
…ot-matched

Fix: translation removed and typescript update
  • Loading branch information
francisco-maciel authored Mar 6, 2018
2 parents 9162f4a + e9ff8bc commit 3db6f09
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/typescript.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/writers/po.writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/writers/portableObject.writer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3db6f09

Please # to comment.