private static IInstallableUnitFragment createLocalizationFragmentOfHost(BundleDescription bd, String hostId, String[] hostManifestValues, Map<Locale, Map<String, String>> hostLocalizations) { InstallableUnitFragmentDescription fragment = new MetadataFactory.InstallableUnitFragmentDescription(); String fragmentId = makeHostLocalizationFragmentId(bd.getSymbolicName()); fragment.setId(fragmentId); fragment.setVersion(PublisherHelper.fromOSGiVersion(bd.getVersion())); // TODO: is this a meaningful version? HostSpecification hostSpec = bd.getHost(); IRequirement[] hostReqs = new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, hostSpec.getName(), PublisherHelper.fromOSGiVersionRange(hostSpec.getVersionRange()), null, false, false, false)}; fragment.setHost(hostReqs); fragment.setSingleton(true); fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); // Create a provided capability for each locale and add the translated properties. ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>(hostLocalizations.keySet().size()); providedCapabilities.add(PublisherHelper.createSelfCapability(fragmentId, fragment.getVersion())); for (Entry<Locale, Map<String, String>> localeEntry : hostLocalizations.entrySet()) { Locale locale = localeEntry.getKey(); Map<String, String> translatedStrings = localeEntry.getValue(); for (Entry<String, String> entry : translatedStrings.entrySet()) { fragment.setProperty(locale.toString() + '.' + entry.getKey(), entry.getValue()); } providedCapabilities.add(PublisherHelper.makeTranslationCapability(hostId, locale)); } fragment.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()])); return MetadataFactory.createInstallableUnitFragment(fragment); }
private static IInstallableUnitFragment createLocalizationFragmentOfHost(BundleDescription bd, String hostId, String[] hostManifestValues, Map<Locale, Map<String, String>> hostLocalizations) { InstallableUnitFragmentDescription fragment = new MetadataFactory.InstallableUnitFragmentDescription(); String fragmentId = makeHostLocalizationFragmentId(bd.getSymbolicName()); fragment.setId(fragmentId); fragment.setVersion(PublisherHelper.fromOSGiVersion(bd.getVersion())); // TODO: is this a meaningful version? HostSpecification hostSpec = bd.getHost(); IRequirement[] hostReqs = new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, hostSpec.getName(), PublisherHelper.fromOSGiVersionRange(hostSpec.getVersionRange()), null, false, false, false)}; fragment.setHost(hostReqs); fragment.setSingleton(true); fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); // Create a provided capability for each locale and add the translated properties. ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<>(hostLocalizations.keySet().size()); providedCapabilities.add(PublisherHelper.createSelfCapability(fragmentId, fragment.getVersion())); for (Entry<Locale, Map<String, String>> localeEntry : hostLocalizations.entrySet()) { Locale locale = localeEntry.getKey(); Map<String, String> translatedStrings = localeEntry.getValue(); for (Entry<String, String> entry : translatedStrings.entrySet()) { fragment.setProperty(locale.toString() + '.' + entry.getKey(), entry.getValue()); } providedCapabilities.add(PublisherHelper.makeTranslationCapability(hostId, locale)); } fragment.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()])); return MetadataFactory.createInstallableUnitFragment(fragment); }
private static IInstallableUnitFragment createLocalizationFragmentOfHost(BundleDescription bd, String hostId, String[] hostManifestValues, Map<Locale, Map<String, String>> hostLocalizations) { InstallableUnitFragmentDescription fragment = new MetadataFactory.InstallableUnitFragmentDescription(); String fragmentId = makeHostLocalizationFragmentId(bd.getSymbolicName()); fragment.setId(fragmentId); fragment.setVersion(PublisherHelper.fromOSGiVersion(bd.getVersion())); // TODO: is this a meaningful version? HostSpecification hostSpec = bd.getHost(); IRequirement[] hostReqs = new IRequirement[] {MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, hostSpec.getName(), PublisherHelper.fromOSGiVersionRange(hostSpec.getVersionRange()), null, false, false, false)}; fragment.setHost(hostReqs); fragment.setSingleton(true); fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); // Create a provided capability for each locale and add the translated properties. ArrayList<IProvidedCapability> providedCapabilities = new ArrayList<IProvidedCapability>(hostLocalizations.keySet().size()); providedCapabilities.add(PublisherHelper.createSelfCapability(fragmentId, fragment.getVersion())); for (Entry<Locale, Map<String, String>> localeEntry : hostLocalizations.entrySet()) { Locale locale = localeEntry.getKey(); Map<String, String> translatedStrings = localeEntry.getValue(); for (Entry<String, String> entry : translatedStrings.entrySet()) { fragment.setProperty(locale.toString() + '.' + entry.getKey(), entry.getValue()); } providedCapabilities.add(PublisherHelper.makeTranslationCapability(hostId, locale)); } fragment.setCapabilities(providedCapabilities.toArray(new IProvidedCapability[providedCapabilities.size()])); return MetadataFactory.createInstallableUnitFragment(fragment); }