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 InputList component to be localizable and support multiple instances on a page. Implement icon localization in Page Add/Edit using IconResources.resx #3179

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

sbwalker
Copy link
Member

No description provided.

…ances on a page. Implement icon localization in Page Add/Edit using IconResources.resx
@sbwalker sbwalker merged commit fb24719 into oqtane:dev Aug 23, 2023
1 check passed
@sbwalker
Copy link
Member Author

@leigh-pointer please test these enhancements. Note that I only added 1 localization key to the IconResources.resx - the other icons would need to be added to this file and would need to use keys of Icon.{Name}. Note that the implementation relies on the ResourceType property which is defined in Page Add/Edit. Other use cases for this component could store their list values in the module's resource file, sharedresources, or whereever they choose.

@sbwalker
Copy link
Member Author

@leigh-pointer the one thing which I am still pondering is whether we are using this Dictionary incorrectly. What I mean is that a Dictionary is comprised of key/value pairs. Keys must be unique but Values do not. In the InputList it is creating a datalist which contains options. Option values in a datalist must be unique whereas the option names do not. So it would seem that the Dictionary Keys should map to the option values and the Dictionary Values should map to the option names - correct? This is opposite of how it is implemented currently.

@leigh-pointer
Copy link
Contributor

@sbwalker i would agree, although it sounds wrong it is in fact correct in a localization stand point!

@sbwalker
Copy link
Member Author

@leigh-pointer if we swapped the keys and values in the Dictionary we could base the localization lookups on the Dictionary Values. To provide more context, I am suggesting:

Icon Dictionary
Key = "oi oi-home"
Value = "Home"

DataList
< option value="oi oi-home" > Home < /option >

RESX file
Key = "Home"
Value = "Translated Value"

@leigh-pointer
Copy link
Contributor

@sbwalker that would work.

@vnetonline
Copy link
Contributor

So can this control, be used for other lists like for example a page list

@leigh-pointer
Copy link
Contributor

@vnetonline it can be use for anything with a key value pair!

@sbwalker
Copy link
Member Author

sbwalker commented Aug 24, 2023

@leigh-pointer I reversed the Dictionary usage and fixed the Icon loader on the server (#3181)

One other item I added is that if you have a one dimensional list of items, you can populate the Dictionary with the keys but simply set the values to "". In this scenario the InputList will use the keys for both the option value and name.

Dictionary:
{ Key = "Option1", Value = ""},
{ Key = "Option2", Value = ""}

DataList
< option value="Option1" > Option1 < /option >
< option value="Option2" > Option2 < /option >

(you could obviously accomplish the same thing by populating both the key and value with the same string)

@leigh-pointer
Copy link
Contributor

@sbwalker pretty cool. I will populate the IconResources File with the Icon data.

@sbwalker
Copy link
Member Author

@leigh-pointer I included an example in the RESX file for Account Login to demonstrate how the icon names can be translated into "friendly" names using localization.

This new component fills a gap between a standard Select element and the AutoComplete component. There are distinct use cases for each of them:

Select - for a smaller list of items, user must select an item from the list
InputList - for a smaller list of items, user can select an item from the list or enter a custom value
AutoComplete - for a large list of items, user can filter list based on input, they must choose an item from the list

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

Successfully merging this pull request may close these issues.

3 participants