/**
 * Functions shared between the schematics.
 **/ import { OptionsAfterSetup } from './options-after-setup' ; import { SchematicContext , Tree } from '@angular-devkit/schematics' ; import { addPackageJsonDependency , NodeDependency , NodeDependencyType } from '../../schematics-core' ; import { xliffmergePackage , xliffmergeVersion } from './constants' ; import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks' ; param lang return export function isValidLanguageSyntax ( lang ) { const pattern = /^[a-zA-Z]{1,8}([-_][a-zA-Z0-9]{1,8})*$/ ; return pattern . test ( lang ) ; } /**
 * returns the build configuration to be set.
 */ export function buildConfigurationForLanguage ( options , language ) { return { aot : true , outputPath : `dist/${ options . project }-${ language }` , i18nFile : `${ options . genDir }/messages.${ language }.xlf` , i18nFormat : options . i18nFormat , i18nLocale : language } ; } /**
 * returns the serve configuration to be set.
 */ export function serveConfigurationForLanguage ( options , language ) { return { browserTarget : `${ options . project }:build:${ language }` } ; } param skipInstall export function addXliffmergeDependencyToPackageJson ( skipInstall ) { return ( host , context ) => { const dependencyToXliffmerge = { type : NodeDependencyType . Dev , name : xliffmergePackage , version : xliffmergeVersion , overwrite : true } ; addPackageJsonDependency ( host , dependencyToXliffmerge ) ; if ( ! skipInstall ) { context . addTask ( new NodePackageInstallTask ( ) ) ; } return host ; } ; }