Skip to content

Commit

Permalink
Changed dynamic language packs to use JSON format, updated format of …
Browse files Browse the repository at this point in the history
…regex definitions
  • Loading branch information
Irrelon committed Apr 19, 2014
1 parent b1e452c commit 0d9e676
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 89 deletions.
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -8,7 +8,7 @@
<script src="js/jquery-lang.js" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript">
var lang = new Lang('en');
lang.dynamic('th', 'js/langpack/th.js');
lang.dynamic('th', 'js/langpack/th.json');
</script>
<style>
body {
Expand Down
36 changes: 31 additions & 5 deletions js/jquery-lang.js
Expand Up @@ -122,15 +122,41 @@ var Lang = (function () {
var self = this;

if (lang && self._dynamic[lang]) {
$.getScript(self._dynamic[lang])
.done(function () {
$.ajax({
dataType: "json",
url: self._dynamic[lang],
success: function (data) {
self.pack[lang] = data;

// Process the regex list
if (self.pack[lang].regex) {
var packRegex = self.pack[lang].regex,
regex,
i;

for (i = 0; i < packRegex.length; i++) {
regex = packRegex[i];
if (regex.length === 2) {
// String, value
regex[0] = new RegExp(regex[0]);
} else if (regex.length === 3) {
// String, modifiers, value
regex[0] = new RegExp(regex[0], regex[1]);

// Remove modifier
regex.splice(1, 1);
}
}
}

console.log('Loaded language pack: ' + self._dynamic[lang]);
if (callback) { callback(false, lang, self._dynamic[lang]); }
})
.fail(function () {
},
error: function () {
console.log('Error loading language pack' + self._dynamic[lang]);
if (callback) { callback(true, lang, self._dynamic[lang]); }
});
}
});
} else {
throw('Cannot load language pack, no file path specified!');
}
Expand Down
83 changes: 0 additions & 83 deletions js/langpack/th.js

This file was deleted.

76 changes: 76 additions & 0 deletions js/langpack/th.json
@@ -0,0 +1,76 @@
{
"token": {
"Property Search":"ค้นหา",
"Location":"สถานที่ตั้ง",
"Min Beds":"จำนวนห้องนอน",
"Property Type":"ชนิดที่อยู่อาศัย",
"Added In":"ลงประกาศเมื่อ",
"Show All":"แสดงผลทั้งหมด",
"House":"บ้าน",
"Town House":"ทาวน์เฮ้าส์",
"Apartment":"อพาร์ทเม้นท์",
"Condominium":"คอนโดมิเนียม",
"Commercial":"อาคารพาณิชย์",
"Office":"ออฟฟิศ",
"Storage":"โกดังเก็บของ",
"Land":"ที่ดินว่างเปล่า",
"Anytime":"แสดงผลทั้งหมด",
"Last 24 Hours":"ชั่วโมงที่ผ่านมา",
"Last 3 Days":"วันที่ผ่านมา",
"Last Week":"สัปดาห์ที่ผ่านมา",
"Last Month":"เดือนที่ผ่านมา",
"Loading":"กำลังประมวลผล",
"My Saved Searches":"การค้นหาที่ถูกเก็บไว้",
"My Listings":"รายการของฉัน",
"My Analytics":"สถิติผู้เข้าชมประกาศของฉัน",
"Search Buy":"ซื้อ",
"Search Rent":"เช่า",
"Create New Listing":"ลงประกาศ",
"View My Account":"ดูข้อมูลของฉัน",
"Property Listing Details":"รายละเอียดประกาศ",
"Listing Type":"ชนิดของประกาศ",
"Sell":"ขาย",
"Let":"เช่า",
"Lease":"เซ้ง",
"Floors":"ชั้น",
"Rooms Total":"จำนวนห้องทั้งหมด",
"Bedrooms":"ห้องนอน",
"Bathrooms":"ห้องน้ำ",
"Kitchens":"ครัว",
"Property Price and Terms":"ราคาและรูปแบบสัญญา",
"Price":"ราคา",
"Term":"สัญญา",
"Freehold":"มีกรรมสิทธิ์",
"Leasehold":"มีระยะสัญญา",
"Possession":"บ้านว่างหรือไม่",
"Onward Chain":"มีผู้อาศัยอยู่",
"Vacant Possession":"บ้านว่างพร้อมเข้าอยู่ทันที",
"Property Location":"สถานที่ตั้ง",
"Country":"ประเทศ",
"Post/Zip Code":"รหัสไปรษณีย์",
"No.":"เลขที่",
"Road Name":"ชื่อถนน",
"County/Province":"จังหวัด",
"Town/City":"อำเภอ",
"Lease Years Remaining":"จำนวนปีของสัญญาที่เหลือ",
"day":"วัน",
"week":"สัปดาห์",
"month":"เดือน",
"quarter":"3 เดือน",
"year":"ปี",
"Submit Your Listing":"ลงประกาศ",
"Upload Image":"ใส่รูป",
"Finish":"เสร็จเรียบร้อย",
"Search":"ค้นหา",
"Search...":"ค้นหา",
"Property Description":"รายละเอียดของประกาศ",
"Synopsis":"รายละเอียดย่อในประกาศ",
"Full Description":"รายละเอียดเพิ่มเติมสำหรับผู้สนใจประกาศ",
"Property Photos":"รูปภาพสถานที่"
},
"regex": [
["Budget", "งบประมาณ"],
["^Something at start of text", ""],
["This will be case insensitive", "i", ""]
]
}

0 comments on commit 0d9e676

Please sign in to comment.