Base solution for your next web application
Open Closed

Best practice for localizing list resources (XML)? #2614


User avatar
0
jcompagnon created

Hello, nice job on the framework!

I was wondering if there were suggested best practices /avenues for localizing list data (as might be used in setting dropdowns, related radio groups, or "levels of satisfaction" scales).

I understood from this thread that creating a service to receive a language code & return the list is one option; my question is, what would this look like in the XML scheme?

If possible, I'd like to not have to register each list as a separate Localization Source in the AbpModule, instead being able to specify a source that would include all localizations for all lists, labels, and error resources.

I'd appreciate any tips, leads or re-orientations!


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    If your list data is similar to enums, you can use a localization key syntax like this "Enums.{EnumTypeName}.{EnumName}". This way, you can create methods to retrieve list of localizable data or a single item's localized value.

    What do you think ?

  • User Avatar
    0
    jcompagnon created

    Thank you for the response!

    If I understand correctly, the idea would be to create an Enum model of each list, with the Enum elements being the keys used to fetch the localized string from the XML?

    I do like this as an option if there were a small number of fairly short lists; however, if there are many & larger lists, then having to create an Enum with all the elements mapped per list, seems like it could get tedious. Ideally, we'd want a dev to be able to receive the XML from a BA, plug it in, and then be able to use the resources directly.

    I was hoping there was some way to mark a list within the XML itself and have the resource manager pick out text by parent-list name; it doesn't look like that's currently possible though.

    One alternative might be to have separate Localization Sources for each list, but to do this and still have a plug-and-play approach for the resource files, I could, for instance, loop through all resource-bearing folders in my app's "/localization" directory, using the folder names as source names. In this way, I could receive a "ListICD9" folder with localized XML files therein, add this to my "/localization" directory, and be able to retrieve the list values by calling the "ListICD9" source.

    Do you think this approach would be workable?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Ok, in your case the method you are thinking is better, you can implement it like that.