use of org.xwiki.localization.TranslationBundle in project xwiki-platform by xwiki.
the class DefaultTranslationBundleContext method initializeCurrentBundles.
private SortedSet<TranslationBundle> initializeCurrentBundles() {
SortedSet<TranslationBundle> currentBundles = new TreeSet<>();
try {
ComponentManager componentManager = this.componentManagerProvider.get();
List<TranslationBundle> availableBundles = componentManager.<TranslationBundle>getInstanceList(TranslationBundle.class);
currentBundles.addAll(availableBundles);
} catch (ComponentLookupException e) {
this.logger.error("Failed to lookup Bundle components", e);
}
return currentBundles;
}
use of org.xwiki.localization.TranslationBundle in project xwiki-platform by xwiki.
the class DefaultLocalizationManager method use.
@Override
public void use(String bundleType, String bundleId) throws TranslationBundleDoesNotExistsException, TranslationBundleFactoryDoesNotExistsException {
TranslationBundle bundle = getTranslationBundle(bundleType, bundleId);
this.bundleContext.addBundle(bundle);
}
use of org.xwiki.localization.TranslationBundle in project xwiki-platform by xwiki.
the class JARTranslationBundleFactoryListener method extensionDeleted.
/**
* @param extension the installed extension
* @param namespace the namespace where the extension has been installed
*/
private void extensionDeleted(InstalledExtension extension, String namespace) {
try {
ComponentDescriptor<TranslationBundle> descriptor = createComponentDescriptor(extension);
ComponentManager componentManager = this.componentManagerManager.getComponentManager(namespace, false);
componentManager.unregisterComponent(descriptor);
} catch (Exception e) {
this.logger.error("Failed to create TranslationBundle descriptor for extension [{}]", extension, e);
}
}
use of org.xwiki.localization.TranslationBundle in project xwiki-platform by xwiki.
the class JARTranslationBundleFactoryListener method extensionAdded.
/**
* @param extension the uninstalled extension
* @param namespace the namespace from where the extension has been uninstalled
*/
private void extensionAdded(InstalledExtension extension, String namespace) {
try {
File jarFile = new File(extension.getFile().getAbsolutePath());
ComponentManager componentManager = this.componentManagerManager.getComponentManager(namespace, false);
if (componentManager == null) {
componentManager = this.rootComponentManager;
}
JARFileTranslationBundle bundle = new JARFileTranslationBundle(jarFile, componentManager, this.translationParser);
ComponentDescriptor<TranslationBundle> descriptor = createComponentDescriptor(jarFile.toURI().toURL());
componentManager.registerComponent(descriptor, bundle);
} catch (Exception e) {
this.logger.error("Failed to register a TranslationBundle component for extension [{}] on namespace [{}]", extension, namespace, e);
}
}
use of org.xwiki.localization.TranslationBundle in project xwiki-platform by xwiki.
the class DocumentTranslationBundleFactory method getOnDemandDocumentBundle.
/**
* Get non-component bundle.
*/
private TranslationBundle getOnDemandDocumentBundle(DocumentReference documentReference) throws TranslationBundleDoesNotExistsException {
String uid = this.uidSerializer.serialize(documentReference);
TranslationBundle bundle = this.onDemandBundleCache.get(uid);
if (bundle == null) {
synchronized (this.onDemandBundleCache) {
bundle = this.onDemandBundleCache.get(uid);
if (bundle == null) {
bundle = createOnDemandDocumentBundle(documentReference, uid);
this.onDemandBundleCache.set(uid, bundle);
}
}
}
return bundle;
}
Aggregations