5

Strategy to display value for a html select

I have a spring boot, application. On the client side, I use JQuery

I would like to know the strategy to display "static value" for a html select.

Example

In the table communicationType I have:

1 - mobile
2 - fix
3 - email

Actually, I put directly the data in the html select.

Not nice for internationalization. Maybe it's not good to put this in a database.

Maybe it's better to don't have a table for this kind of data? Is it better to create an enum, put enum value in a properties file? Put value in db but use a kind of key for the string and put this key in a properties file?

2
  • 1
    It's hard to tell - is your question "How do I do internationalization with Java spring boot"? Jun 13, 2016 at 15:14
  • Basically, this question is How do I internationalize a List of Values when they are stored in the database? Frankly, I have the same question. I'm dealing with an application right now with lots of List of Values (dropdown lists) populated by data from a database, where the display text is stored in the DB. Feb 9, 2017 at 18:57

2 Answers 2

1

Your question deals with several topics:

I) As you already noticed: hard coding something in HTML is very unflexible. You should avoid that.

II) The values of your select represent a list of data. The place to keep your data is typically some knd of database. The format you store it in is the canonical form for your application (whatever language you use internally).

III) Outside of your application, you use an internationalized representation of your canonical form. That involves somewhere a translation-step in your rendering pipeline.

Tutorial for Spring Boot

Where you store the translated strings is up to you and your application; the common way is properties.

0

You could specify localization by passing an argument to a backend API that returns a list of text values. You could also perform localization client-side. The storage medium isn't going to help you here in the sense that you must map to a single representation regardless so storing it in a relational structure could involve a fair amount of complexity. A 'properties' file is probably not the best place for this. Once you have the localized data, you can insert it via JavaScript (for example with the jQuery library).

1
  • could be maybe a better idea to have an enum for this kind of data and use enum value in a properties file to get i18n value. Jun 14, 2016 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.