Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow crossreferencing of labels between fields and presets #162

Open
Dimitar5555 opened this issue Jun 6, 2024 · 0 comments
Open

Allow crossreferencing of labels between fields and presets #162

Dimitar5555 opened this issue Jun 6, 2024 · 0 comments

Comments

@Dimitar5555
Copy link

Simply having {preset/....} or {field/....} should allow to use the respective label. If there the keywords (preset/field) aren't present, the script should default to the translations of the current item.

Such change would require changes in two places and could be taken out in a separate function.

https://github.com/ideditor/schema-builder/blob/main/lib/build.js#L529-L531

https://github.com/ideditor/schema-builder/blob/main/lib/build.js#L566-L568

function fetchLabel(label, type, tstrings) {
	label = label.slice(1, -1);
	let separated = label.split('/');
	let labelType = separated.shift();
	let searchIn = tstrings[type];
	let labelAccessName  = type=='preset'?'name':'label';
	if(['preset', 'field'].indexOf(labelType) != -1) {
		searchIn = tstring[labelType];
		labelAccessName  = labelType=='preset'?'name':'label';
	}
	return searchIn[label][labelAccessName];
}

P.S. It might be a good idea for presets to have label instead of name, at least for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant