希望你在做文件轉換.string文件格式轉化成PHP數組格式
因此,這裏是我的問題,我有一個用於translation.Please一個xyz.string文件中找到以下文件的一小部分。
/* name for an item that is duplicated in the UI, based on the original name */
"%@ (Copy)" = "%@ (kopi)";
/* display name for a book page template that is the first page of that section */
"%@ (First)" = "%@ (Første)";
/* display name for a book page template that represents a hardcover cover. the second argument is the cover type. */
"%@ (Hardcover, %@)" = "%[email protected] (Hard innbinding, %[email protected])";
/* display name for a book page template that represents a softcover cover. the second argument is the cover type. */
"%@ (Softcover, %@)" = "%[email protected] (myk innbinding, %[email protected])";
我想翻譯即轉換成一個PHP數組一樣
array(
array{
"%@ (First)"=>"%@ (Første)"
},
array
{
"@ (Hardcover, %@)"=>"%[email protected] (Hard innbinding, %[email protected])"
}
)
等被指定on.The格式不是強制性的,但它應該是,我可以解決方法。
以下是文件格式
鍵 - 值對被分隔與等於字符(=)的以分號結束的說明書,和 (;)。
鍵和值由雙引號(「)包圍
佔位符的外觀可以是:%.2f,%d,%1個$ S(正則表達式 佔位符:/%[\ d |。] \ $ \ d * [DSF] {1} \ B + /)
註釋開始在該行的開始和跨越整個線 或多行
單行註釋開始用雙斜線(//)多線 註釋被包圍在/ * */
除非有任何 空白行評論被分配給下一個鍵 - 值對
之間
我知道這可以通過PREG_MATCH_ALL來實現,但是我不能夠創建一個漂亮的正則表達式
下面是我的代碼
$str=file_get_contents($_FILES['string']['tmp_name']);
preg_match_all("|(\".+\"\;)|s",preg_quote($str),$match);
echo "<pre/>";print_r($match);die;
file_get_content後,我得到確切的字符串以下
/* name for an item that is duplicated in the UI, based on the original name */ "%@ (Copy)" = "%@ (kopi)"; /* display name for a book page template that is the first page of that section */ "%@ (First)" = "%@ (Første)"; /* display name for a book page template that represents a hardcover cover. the second argument is the cover type. */ "%@ (Hardcover, %@)" = "%[email protected] (Hard innbinding, %[email protected])";
如果有人能幫助我在這一點,我們將不勝感激
感謝 瑞安
我認爲它會工作,但它的工作原理不工作我沒有得到任何東西在匹配數組中,請找到確切的字符串,我得到的文件file_get_content在我的nxt註釋 –
/*名稱爲基於原始名稱重複在UI中的項目* /「%@ (複製)「=」%@(kopi)「;/*顯示該部分第一頁的書頁模板的名稱* /」%@(First)「=」%@(Første)「;/*顯示書名頁面模板的名稱,表示精裝封面,第二個參數是封面類型。* /「%@(Hardcover,%@)」=「%1 $ @(堅固的建築,%2 $ @)」; –
@Ryandecosta現場演示:http://3v4l.org/OsVQd – revo