简体   繁体   English

如何将.properties文件转换为angular中的json对象

[英]How to convert .properties file to json object in angular

I have a .properties file including following code: 我有一个.properties文件,其中包括以下代码:

MultiLanguageView.language1=Turn off/on first language entries
MultiLanguageView.language2=Turn off/on second language entries
MultiLanguageView.toggle=Display works only/Display all entries

SearchView.headwords=Headwords
SearchView.headwords.tooltip=Headwords search
SearchView.entry=Headword
SearchView.entry.tooltip=Search in Italian headwords and in their French and German translations
SearchView.subentry=Subentry
SearchView.subentry.tooltip=Search in Italian subentries and in their French and German translations
SearchView.fullText=Full text
SearchView.fullText.tooltip=Full text search
SearchView.japentry=Headword (alphabetic)
SearchView.japentry.tooltip=Headwords search with a latin keyboard
SearchView.japentry.jap=Headword (\u6F22\u5B57)
SearchView.japentry.jap.tooltip=Headwords search with ideograms
SearchView.japfullText=Full text (alphabetic)
SearchView.japfullText.tooltip=Full text search with a latin keyboard
SearchView.japfullText.jap=Full text (\u6F22\u5B57)
SearchView.japfullText.jap.tooltip=Full text search with ideograms
SearchView.cinentry=Headword (alphabetic)
SearchView.cinentry.tooltip=Headwords search with a latin keyboard
SearchView.cinentry.cin=Headword (\u4e2d\u6587\u8bcd)
SearchView.cinentry.cin.tooltip=Headwords search with ideograms
SearchView.cinfullText=Full text (alphabetic)
SearchView.cinfullText.tooltip=Full text search with a latin keyboard
SearchView.cinfullText.cin=Full text<br>(\u4e2d\u6587\u8bcd)
SearchView.cinfullText.cin.tooltip=Full text search with ideograms

AdvancedSearchFieldSearchAction.HEADWORD_ADVANCED.results=Headwords: {2} additional entries found for \"{1}\"
AdvancedSearchFieldSearchAction.HEADWORD_ADVANCED.noresults=Headwords: no additional entries found for \"{1}\"

I needed to convert this into nested JSON objects to use ngx-translate in Angular 7. please 我需要将其转换为嵌套的JSON对象,以便在Angular 7中使用ngx-translate。

You can create your custom loader with TranslateLoader on ngx-translate, the only thing you have to do is to parse the property file. 您可以使用ngx-translate上的TranslateLoader创建自定义加载程序,唯一要做的就是解析属性文件。

I do not know this file type but there is maybe a library which understand this file syntax or do your own one. 我不知道这种文件类型,但也许有一个图书馆可以理解这种文件语法或自己做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM