我需要在PHP中解析这种语言,但我不知道它是什么语言以及如何解析它。
有人知道它是什么语言吗?
如果它不是一种语言,有人可以解释我如何解析它吗?
非常感谢
include "folder/file1.conf"
include "folder/file2.conf"
auth-mocked {
welcome = "Welcome"
login = "Login to continue:"
placeholder = "login"
button = "Login"
error = "Error:"
}
auth {
sso {
validation {
expected-uuid = "You need an UID"
}
session-not-found = "session was not found"
}
}
header {
company-name = "Company name"
help-popup {
title = "Need help?"
paragraph = "If you have any issue, you can contact your dedicated interlocutor:"
}
language-popup {
title = "Change language"
}
language = "Change language"
profile = "My profile"
terms-of-use = "Terms of use"
ao-documents = "Documents"
logout = "Logout"
user = "User"
}
black-panel {
common {
form = "You are currently filling the form:"
btn-i-understand = "Ok, thanks"
btn-link-view = "View"
}
}
答案 0 :(得分:0)
我最终创建了自己的解析器来获取每个键的标签。
function parseFile($file){
$title = "";
$key = "";
$value = "";
$str = "";
$array = array();
$results = array();
$lines = file('./generated_json/'.$file);
foreach($lines as $line){
if(strpos($line, " {\n")){
$title = str_replace(" {", "", $line);
array_push($array, $title);
$str = implode(".", $array);
}
if(strpos($line, "=")){
$keyEx = explode("=", $line);
$key = $keyEx[0];
$value = $keyEx[1];
$parsed = $str.".".$key;
$parsed = preg_replace('/\s+/', '', $parsed);
$parsed = str_replace("=", "", $parsed);
array_push($results, $parsed." = ".$value);
}
if(strpos($line, "}\n")){
array_pop($array);
$str = implode(".", $array);
}
}
return $results;
}
答案 1 :(得分:-1)
它可能是一种自制的文件格式,但这里有一个用于翻译的常见文件格式列表: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/formats/
如果你在那里找不到你的文件格式,你可能会为它编写一个解析器。