Skip to content

Commit

Permalink
Merge branch 'master' into import-nand-lal
Browse files Browse the repository at this point in the history
  • Loading branch information
Harjot1Singh committed Jun 21, 2019
2 parents f22eb92 + a07ed74 commit 91b0c62
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,25 @@ const main = async () => {
} ) )

// Generate translation sources for translations
const newTranslationSources = translation.map( ( name, index ) => ( {
id: newTranslationSourceId + index,
name_gurmukhi: name,
name_english: name,
source_id: newSourceId,
language_id: -1,
} ) )
const newTranslationSources = sources.map( ( _, sourceIndex ) =>
translation.map( ( name, index ) => ( {
id: ( translation.length * sourceIndex ) + newTranslationSourceId + index,
name_gurmukhi: name,
name_english: name,
source_id: newSourceId + sourceIndex,
language_id: -1,
} ) ) )
.reduce( ( AllSources, translationSources ) => AllSources.concat( translationSources ), [] )

// Generate the translations
const newTranslations = translation
.map( ( name, index ) => lines.map( ( data, lineIndex ) => ( {
line_id: newLineIDs[ lineIndex ],
translation_source_id: newTranslationSourceId + index,
translation_source_id: (
newTranslationSourceId
+ index
+ sources.findIndex( sourceName => sourceName === data[ source ] )
),
translation: data[ name ] || '',
additional_information: '{}',
} ) ) )
Expand Down

0 comments on commit 91b0c62

Please sign in to comment.