playframework - Internationalization for user defined input -
i'm trying build localization
user defined input. example: user define categories soccer in several languages.
the model entity have filed this:
@manytomany @mapkeycolumn(name = "locale", insertable = false, updatable = false) public map<string, l18n> titles;
i'd store localized strings this:
@entity public class l18n { @id @constraints.required @formats.nonempty public integer id; public string key; public string locale; @column(columndefinition = "text") public string text; }
we use yaml store testdata:
category: - !!models.category ... titles: - !!models.l18n key: soccer l18n: - !!models.l18n key: soccer locale: de-ch text: fdfdfsee - !!models.l18n key: soccer locale: fr-ch text: dlfkjsdlfj
with solution i'm getting error:
[error] caused by: org.yaml.snakeyaml.error.yamlexception: no suitable constructor 1 arguments found interface java.util.map [error] @ org.yaml.snakeyaml.constructor.constructor$constructsequence.construct(constructor.java:574) [error] @ org.yaml.snakeyaml.constructor.baseconstructor.constructobject(baseconstructor.java:182) [error] @ org.yaml.snakeyaml.constructor.constructor$constructmapping.constructjavabean2ndstep(constructor.java:296) [error] ... 65 more
i think problem you've defined titles map, don't use yaml mapping syntax define it. yaml collections
i think syntax titles should example here using langauges: yaml dictionary example
titles: soccer: - !!models.l18n key: soccer locale: de-ch text: fdfdfsee football: - !!models.l18n ...
if change format of .yml file l18n instances defined first , use references, yaml spec calls them alias nodes, make titles lot more streamlined:
l18n: - &soccerde !!models.l18n key: soccer locale: de-ch text: fdfdfsee - &soccerfr !!models.l18n key: soccer locale: fr-ch text: dlfkjsdlfj category: - !!models.category ... titles: soccerde: *soccerde soccerfr: *soccerfr
Comments
Post a Comment