UNPKG

@digitalartlab/expo-plugin-localization

Version:
27 lines (26 loc) 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withIosLocalizableProject = void 0; const config_plugins_1 = require("expo/config-plugins"); /** * Adds a Localizable.strings file reference to the Xcode project for each locale. This is necessary for Xcode to recognize the various languages. */ const withIosLocalizableProject = (config, { locales }) => { return (0, config_plugins_1.withXcodeProject)(config, async (config) => { const xcodeProject = config.modResults; locales.forEach((locale) => { // Add the locale to the project // Deduplication is handled by the function xcodeProject.addKnownRegion(locale); }); xcodeProject.addPbxGroup("Resources", "Resources"); const localizationVariantGp = xcodeProject.addLocalizationVariantGroup("Localizable.strings"); const localizationVariantGpKey = localizationVariantGp.fileRef; locales.forEach((locale) => { // Create a file reference for each locale xcodeProject.addResourceFile(`Resources/${locale}.lproj/Localizable.strings`, { variantGroup: true }, localizationVariantGpKey); }); return config; }); }; exports.withIosLocalizableProject = withIosLocalizableProject;