function updateLocale(i18nKeys, locale, namespace, pattern, sort) {
	const filePath = getPathFromPattern(pattern, namespace, locale);
	let savedLocale = {};
	if (fs.existsSync(filePath)) {
		// eslint-disable-next-line global-require
		savedLocale = getJSON(filePath);
	}

	// find the difference between the code & the dictionary. prior is the code
	// remove unused keys
	// add new keys
	const keys = [
		...intersection([...i18nKeys.keys()], Object.keys(savedLocale)),
		...difference([...i18nKeys.keys()], Object.keys(savedLocale)),
	];

	// set value that exist in the current locale or set defaultValue (only for en)
	const newLocale = keys.reduce(
		(refreshedLocale, key) => ({
			...refreshedLocale,
			[key]: savedLocale[key] || (locale === DEFAULT_LOCALE ? i18nKeys.get(key) : ''),
		}),
		{},
	);

	mkdirp.sync(path.dirname(filePath));
	fs.writeFileSync(
		filePath,
		JSON.stringify(sort ? sortObject(newLocale) : newLocale, null, '  ') + String.fromCharCode(10),
	);
}
/**
 * updateLocale - adding or removing unused keys/values
 * 								write the new locale
 *
 * @param  {Map} i18nKeys        key/value used in the projets
 * @param  {string} locale       current locale
 * @param  {string} namespace    current namespace
 * @param  {string} pattern      pattern to get the locale

 */
adding or removing unused keys/values
write the new locale

@param  {Map} i18nKeys        key/value used in the projets
@param  {string} locale       current locale
@param  {string} namespace    current namespace
@param  {string} pattern      pattern to get the locale
adding or removing unused keys / values write the new locale @param { Map } i18nKeys key / value used in the projets @param { string } locale current locale @param { string } namespace current namespace @param { string } pattern pattern to get the locale
function updateLocale(i18nKeys, locale, namespace, pattern, sort) {
	const filePath = getPathFromPattern(pattern, namespace, locale);
	let savedLocale = {};
	if (fs.existsSync(filePath)) {
		savedLocale = getJSON(filePath);
	}
	const keys = [
		...intersection([...i18nKeys.keys()], Object.keys(savedLocale)),
		...difference([...i18nKeys.keys()], Object.keys(savedLocale)),
	];
	const newLocale = keys.reduce(
		(refreshedLocale, key) => ({
			...refreshedLocale,
			[key]: savedLocale[key] || (locale === DEFAULT_LOCALE ? i18nKeys.get(key) : ''),
		}),
		{},
	);
	mkdirp.sync(path.dirname(filePath));
	fs.writeFileSync(
		filePath,
		JSON.stringify(sort ? sortObject(newLocale) : newLocale, null, '  ') + String.fromCharCode(10),
	);
}
function updateLocale ( i18nKeys , locale , namespace , pattern , sort ) { const filePath = getPathFromPattern ( pattern , namespace , locale ) ; let savedLocale = { } ; if ( fs . existsSync ( filePath ) ) { savedLocale = getJSON ( filePath ) ; } const keys = [ ... intersection ( [ ... i18nKeys . keys ( ) ] , Object . keys ( savedLocale ) ) , ... difference ( [ ... i18nKeys . keys ( ) ] , Object . keys ( savedLocale ) ) , ] ; const newLocale = keys . reduce ( ( refreshedLocale , key ) => ( { ... refreshedLocale , [ key ] : savedLocale [ key ] || ( locale === DEFAULT_LOCALE ? i18nKeys . get ( key ) : '' ) , } ) , { } , ) ; mkdirp . sync ( path . dirname ( filePath ) ) ; fs . writeFileSync ( filePath , JSON . stringify ( sort ? sortObject ( newLocale ) : newLocale , null , '  ' ) + String . fromCharCode ( 10 ) , ) ; }
updateLocale - adding or removing unused keys/values
                                                              write the new locale
updateLocale - adding or removing unused keys / values write the new locale
// eslint-disable-next-line global-require // find the difference between the code & the dictionary. prior is the code // remove unused keys // add new keys // set value that exist in the current locale or set defaultValue (only for en)