How to use the liferay-npm-build-tools-common/lib/project.l10n function in liferay-npm-build-tools-common

To help you get started, we’ve selected a few liferay-npm-build-tools-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / jar / index.js View on Github external
function addSystemConfigurationFiles(zip) {
	const systemConfigJson = getSystemConfigurationJson();

	if (!systemConfigJson) {
		return;
	}

	// Add OSGI-INF/metatype/metatype.xml file
	const localization = project.l10n.supported
		? `content/${path.basename(project.l10n.languageFileBaseName)}`
		: undefined;

	const name =
		systemConfigJson.name ||
		(localization ? pkgJson.name : pkgJson.description || pkgJson.name);

	const metatype = xml.createMetatype(pkgJson.name, name);

	if (localization) {
		xml.addMetatypeLocalization(metatype, localization);
	}

	const fields = Object.entries(systemConfigJson.fields);

	fields.forEach(([id, desc]) => {
		xml.addMetatypeAttr(metatype, id, desc);
github liferay / liferay-js-toolkit / packages / liferay-npm-build-support / src / scripts / translate.js View on Github external
export default function() {
	if (!project.l10n.supported) {
		console.log(
			'Project does not support localization: nothing to translate.\n\n'
		);

		process.exit(3);
	}

	let subscriptionKey = process.env.TRANSLATOR_TEXT_KEY;

	if (!subscriptionKey) {
		subscriptionKey = cfg.getTranslatorTextKey();
	}

	if (!subscriptionKey || subscriptionKey == '') {
		console.error(
			'-------------------------------------------------------------\n' +
github liferay / liferay-js-toolkit / packages / liferay-npm-build-support / src / scripts / translate.js View on Github external
'-------------------------------------------------------------\n' +
				'    🛑 Microsoft Translator credentials not set 🛑\n\n' +
				'Please set the translatorTextKey variable in your .npmbuildrc\n' +
				'file or provide them in the TRANSLATOR_TEXT_KEY environment\n' +
				'variable.\n' +
				'-------------------------------------------------------------\n'
		);

		process.exit(2);
	}

	showMissingSupportedLocales();

	createMissingSupportedLocalesFiles();

	const localizationFileMap = project.l10n.localizationFileMap;

	const locales = Object.keys(localizationFileMap).filter(
		locale => locale != 'default'
	);

	if (locales.length == 0) {
		console.log(
			'No locales found: nothing to translate.\n\n' +
				'You can edit your .npmbuildrc file to add new supported ' +
				"locales using the 'supportedLocales' array.\n"
		);
		return;
	}

	console.log(`\nFound ${locales.length} locales: ${locales.join(', ')}\n`);
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / jar / index.js View on Github external
contents += `Tool: liferay-npm-bundler-${bundlerVersion}\n`;

	contents += `Bundle-SymbolicName: ${pkgJson.name}\n`;
	contents += `Bundle-Version: ${pkgJson.version}\n`;
	if (pkgJson.description) {
		contents += `Bundle-Name: ${pkgJson.description}\n`;
	}

	contents += `Web-ContextPath: ${config.jar.getWebContextPath()}\n`;

	contents +=
		`Provide-Capability: osgi.webresource;` +
		`osgi.webresource=${pkgJson.name};` +
		`version:Version="${pkgJson.version}"\n`;

	if (project.l10n.supported) {
		const bundleName = path.basename(project.l10n.languageFileBaseName);

		contents += `Provide-Capability: liferay.resource.bundle;`;
		contents += `resource.bundle.base.name="content.${bundleName}"\n`;
	}

	if (config.jar.getRequireJsExtender()) {
		let filter;

		const minimumExtenderVersion = getMinimumExtenderVersion();

		if (minimumExtenderVersion) {
			filter =
				`(&` +
				`(osgi.extender=liferay.frontend.js.portlet)` +
				`(version>=${minimumExtenderVersion})` +
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / jar / index.js View on Github external
function addLocalizationFiles(zip) {
	const languageFileBaseName = project.l10n.languageFileBaseName;

	if (languageFileBaseName) {
		const localizationDirPath = path.dirname(languageFileBaseName.asNative);

		addFiles(localizationDirPath, ['**/*'], zip.folder('content'));
	}
}
github liferay / liferay-js-toolkit / packages / liferay-npm-bundler / src / jar / index.js View on Github external
contents += `Tool: liferay-npm-bundler-${bundlerVersion}\n`;

	contents += `Bundle-SymbolicName: ${pkgJson.name}\n`;
	contents += `Bundle-Version: ${pkgJson.version}\n`;
	if (pkgJson.description) {
		contents += `Bundle-Name: ${pkgJson.description}\n`;
	}

	contents += `Web-ContextPath: ${project.jar.webContextPath}\n`;

	contents +=
		`Provide-Capability: osgi.webresource;` +
		`osgi.webresource=${pkgJson.name};` +
		`version:Version="${pkgJson.version}"\n`;

	if (project.l10n.supported) {
		const bundleName = path.basename(
			project.l10n.languageFileBaseName.asNative
		);

		contents += `Provide-Capability: liferay.resource.bundle;`;
		contents += `resource.bundle.base.name="content.${bundleName}"\n`;
	}

	if (project.jar.requireJsExtender) {
		let filter;

		const minimumExtenderVersion = getMinimumExtenderVersion();

		if (minimumExtenderVersion) {
			filter =
				`(&` +