ทดสอบแอปด้วยภาษาจำลอง (pseudolocale)
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ภาษาจำลองคือภาษาที่ออกแบบมาเพื่อจำลองลักษณะของภาษาที่ทำให้เกิดปัญหาเกี่ยวกับ UI, เลย์เอาต์ และอื่นๆ ที่เกี่ยวข้องกับการแปลเมื่อมีการแปลแอป ภาษาจำลองสร้างขึ้นโดยการแปลทันทีและอัตโนมัติที่อ่านเป็นภาษาอังกฤษได้สำหรับข้อความที่แปลได้ทั้งหมด
ข้อความที่ยังไม่ได้แปลจำลองจะชี้ไปยังข้อความที่แปลไม่ได้ในซอร์สโค้ด
ภาษาจำลองช่วยประหยัดเวลาและค่าใช้จ่าย เนื่องจากคุณสามารถปรับแต่งข้อความ UI และเลย์เอาต์ก่อนที่จะส่งข้อความไปยังที่เก็บต้นทางเพื่อส่งให้แปลในภายหลัง ดูรายการปัญหาที่อาจเกิดขึ้นในการแปลได้ที่ส่วนตรวจหาปัญหาการแปล
รูปที่ 1 ภาษาจำลองภาษาอังกฤษ (XA)
ชื่อภาษาจำลองของ Android เป็นไปตามรูปแบบการตั้งชื่อภาษามาตรฐาน และภาษาโปรแกรมใดก็ได้ที่เป็นไปตามข้อกำหนด BCP 47 จะแยกวิเคราะห์รหัสภาษาได้
ในแง่นี้ ภาษาจำลองจึงเหมือนกับภาษาอื่นๆ เช่น ฝรั่งเศส จีน หรือรัสเซีย
แพลตฟอร์ม Android มีภาษาจำลอง 2 ภาษาต่อไปนี้เพื่อแสดงภาษาจากซ้ายไปขวา (LTR) และจากขวาไปซ้าย (RTL)
รูปที่ 2 ภาษาจำลอง AR (XB)
อังกฤษ (XA): เพิ่มเครื่องหมายกำกับการออกเสียงภาษาละตินลงในข้อความ UI ภาษาอังกฤษพื้นฐาน ขยายข้อความต้นฉบับด้วยการเพิ่มข้อความที่ไม่มีเครื่องหมายกำกับการออกเสียง และใส่วงเล็บเหลี่ยมรอบๆ แต่ละหน่วยข้อความเพื่อแสดงปัญหาที่อาจเกิดขึ้นจากข้อความที่ขยาย ปัญหาที่อาจเกิดขึ้นได้คือการจัดวางที่ขาดตอนและรูปแบบข้อความที่ไม่เป็นระเบียบ เช่น ประโยคที่แบ่งออกเป็นหลายส่วนซึ่งแสดงเป็นข้อความที่มีวงเล็บหลายรายการ ภาษาจำลองภาษาอังกฤษ (XA) จะแสดงในรูปที่ 1
AR (XB): ตั้งค่าทิศทางข้อความของข้อความต้นฉบับจากซ้ายไปขวาเป็นจากขวาไปซ้าย ซึ่งจะกลับลําดับของอักขระในข้อความต้นฉบับ ภาษาจำลอง AR (XB) แสดงในรูปที่ 2
ภาษาจำลองจะช่วยคุณสร้างแอปเวอร์ชัน RTL ได้ แม้ว่าคุณจะไม่ได้เขียนหรือพูดภาษา RTL ก็ตาม
เปิดใช้ภาษาจำลอง
โดยปกติแล้ว ระบบจะเพิ่มภาษาจำลองลงในบิลด์ที่มุ่งเน้นนักพัฒนาแอป เมื่อคุณเลือกภาษาจำลองในอุปกรณ์ แอปทั้งหมดที่รองรับภาษาจำลองจะมีลักษณะของภาษาจำลองที่เลือก รวมถึงแอประบบทั้งหมด เช่น แอปการตั้งค่าและแผงการตั้งค่าด่วน
หากต้องการใช้ภาษาจำลองของ Android คุณต้องใช้งาน Android 4.3 (API ระดับ 18) ขึ้นไปและเปิดใช้ตัวเลือกสำหรับนักพัฒนาแอปในอุปกรณ์ นอกจากนี้ คุณยังต้องรีบูตอุปกรณ์หลังจากเปิดใช้ตัวเลือกสำหรับนักพัฒนาแอปด้วย
ขั้นตอนต่อไปนี้จะอธิบายวิธีเปิดใช้ภาษาจำลอง
ใน Android Studio ให้เปิดใช้ภาษาจำลองสําหรับแอปที่เฉพาะเจาะจงโดยเพิ่มการกําหนดค่าต่อไปนี้ลงในไฟล์ build.gradle
Kotlin
android {
...
buildTypes.getByName("debug") {
isPseudoLocalesEnabled = true
}
}
สร้างและเรียกใช้แอป
รูปที่ 3 เลือกภาษาจำลอง
ใช้แอปการตั้งค่าเพื่อเลือกภาษาจำลอง ขั้นตอนนี้จะแตกต่างกันไปตามเวอร์ชัน Android ดังนี้
Android 5.0 (API ระดับ 21) ขึ้นไป
- เปิดแอปการตั้งค่าในอุปกรณ์ แล้วแตะภาษาและการป้อนข้อมูล >
ค่ากำหนดภาษา
- ในรายการค่ากําหนดภาษา ให้ลากแท็บเพื่อย้ายภาษาจำลองไปที่ด้านบนของรายการ แล้วทําให้เป็นภาษาที่ใช้งานอยู่
โปรดดูรูปที่ 3
Android 4.4.4 (API ระดับ 19) หรือต่ำกว่า
- ในอุปกรณ์ ให้เปิดแอปการตั้งค่า แล้วแตะภาษาและการป้อนข้อมูล >
ค่ากำหนดภาษา > เพิ่มภาษา
- แตะภาษาจำลองเพื่อเพิ่มลงในรายการค่ากําหนดภาษา
- ในรายการค่ากําหนดภาษา ให้ลากแท็บเพื่อย้ายภาษาจำลองไปที่ด้านบนของรายการ แล้วทําให้เป็นภาษาที่ใช้งานอยู่ ดูรูปที่ 3
ปัญหาการแปลภาษาของจุด
ภาษาจำลองเป็นวิธีที่ประหยัดเวลาและมีประสิทธิภาพในการค้นหาปัญหาที่อาจเกิดขึ้นเกี่ยวกับความสามารถในการแปลใน UI โดยช่วยให้คุณระบุปัญหาในด้านต่อไปนี้ได้
- สตริงแบบฮาร์ดโค้ดที่ส่งไปยังการแปลไม่ได้จะแสดงเป็นข้อความที่ไม่มีเครื่องหมายกำกับการออกเสียงในภาษาจำลองเพื่อให้สังเกตเห็นได้
- ปัญหาเลย์เอาต์ UI ที่เกิดจากข้อความที่ขยาย ซึ่งแสดงตำแหน่งที่ UI อาจแบ่งบรรทัดเนื่องจากความยาวของข้อความ
การต่อสตริง ซึ่งจะแสดงเป็นข้อความเดียวที่แบ่งออกเป็นวงเล็บ 2 ตัวขึ้นไป ซึ่งอาจทำให้การแปลที่ถูกต้องทำได้ยาก เนื่องจากผู้แปลต้องแปลแต่ละส่วนแยกกันโดยไม่รู้ว่าส่วนต่างๆ นั้นเกี่ยวข้องกัน นอกจากนี้ การต่อสตริงยังทําให้แปลไม่ถูกต้องได้ เนื่องจากภาษาต่างๆ อาจต้องใช้ลําดับของส่วนต่างๆ ที่แตกต่างกันหรือโครงสร้างประโยคที่แตกต่างออกไปโดยสิ้นเชิง เช่น ภาษาเกาหลี ญี่ปุ่น และภาษาทมิฬจะวางกริยาไว้ที่ท้ายประโยค เมื่อมีการต่อประโยคกัน นักแปลจะเปลี่ยนลําดับคําตามต้องการไม่ได้
ปัญหาข้อความแบบ 2 ทิศทาง (BIDI) เช่น เมื่อเนื้อหาในทิศทางข้อความหนึ่งมีวลีในบรรทัดในทิศทางข้อความตรงข้าม ซึ่งทำให้อ่านสตริงได้ยาก
ปัญหาเกี่ยวกับภาษาจากขวาไปซ้าย (RTL) เช่น องค์ประกอบไม่ได้รับการมิเรอร์ ตัวอย่างบางส่วน ได้แก่ องค์ประกอบ UI ไม่เลื่อนไปทางซ้าย ข้อความไม่กลับด้านและเลื่อนไปทางซ้าย หรือเครื่องหมายวรรคตอนอยู่ผิดที่ เช่น "pseudolocales rule!" เปลี่ยนเป็น "elur selacoloduesp!" แทนที่จะเป็น "!elur selacoloduesp"
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Test your app with pseudolocales\n\nA pseudolocale is a locale that is designed to simulate characteristics of\nlanguages that cause UI, layout, and other translation-related problems when an\napp\nis translated. Pseudolocales are created by instant and automatic translations\nthat are readable in English for all *localizable* messages.\nUn-pseudolocalized text points to untranslatable messages in your source code.\n\nPseudolocales save time\nand money because you can make adjustments to the UI text and its layout before\nyou commit your messages to the source repository to be sent for translation\nlater. For a list of potential translation problems, see the\n[Spot localization issues](#spot_localization_issues) section. \n\n**Figure 1.** English (XA) pseudolocale.\n\nThe Android pseudolocale names follow standard locale naming conventions, and\ntheir locale IDs can be parsed by any BCP 47 compliant programming language.\nIn this sense, pseudolocales are just like any other locales, such as French,\nChinese, or Russian.\n\nThe Android platform provides the following two pseudolocales to represent\nleft-to-right (LTR) and right-to-left (RTL) languages: \n\n**Figure 2.** AR (XB) pseudolocale.\n\n**English (XA):** adds Latin accents to the base English UI text, expands the\noriginal text by adding non-accented text, and brackets each message unit to\nexpose potential issues from expanded text. Potential issues can be layout\nbreakage and badly formed message syntax, such as a sentence split\ninto multiple parts displaying as multiple bracketed messages. The English (XA)\npseudolocale is shown in figure 1.\n\n**AR (XB):** sets the text direction of the original left-to-right messages to\nthe right-to-left direction, which reverses the order of the characters in the\noriginal message. The AR (XB) pseudolocale is shown in figure 2.\n\nPseudolocales can help you make an RTL version of your app, even if you don't\nwrite or speak any RTL languages.\n\nEnable pseudolocales\n--------------------\n\nPseudolocales are usually added to developer-oriented builds. When you choose a\npseudolocale on your device, all the apps that support pseudolocales take on\nthe characteristics of the selected pseudolocale, including all the system apps\nsuch as the Settings app and Quick Settings panel.\n\n\u003cbr /\u003e\n\n\nTo use the Android pseudolocales, you must be running\nAndroid 4.3 (API level 18) or higher and have\n[developer options](/studio/debug/dev-options) enabled\non your device. You must also reboot your device after enabling\ndeveloper options.\n\nThe following procedure explains how to enable pseudolocales:\n\n1. In Android Studio, enable pseudolocales for a specific app by adding the\n following configuration to your `build.gradle` file:\n\n ### Groovy\n\n ```groovy\n android {\n ...\n buildTypes {\n debug {\n pseudoLocalesEnabled true\n }\n }\n }\n ```\n\n ### Kotlin\n\n ```kotlin\n android {\n ...\n buildTypes.getByName(\"debug\") {\n isPseudoLocalesEnabled = true\n }\n }\n ```\n2. [Build and run your app](/studio/run).\n\n **Figure 3.** Select a pseudolocale.\n3. Use the Settings app to select a pseudolocale. This step varies based on your\n Android version, as follows:\n\n **Android 5.0 (API level 21) or higher**\n 1. On the device, open the Settings app and tap **Languages and input \\\u003e\n Language preferences**.\n 2. In the **Language preferences** list, drag the tab to move a pseudolocale to the top of the list and make it the active language. See figure 3.\n\n **Android 4.4.4 (API level 19) or lower**\n 1. On the device, open the Settings app and tap **Languages and input \\\u003e\n Language preferences \\\u003e Add a language**.\n 2. Tap a pseudolocale to add it to the **Language preferences** list.\n 3. In the **Language preferences** list, drag the tab to move a pseudolocale to the top of the list and make it the active language See figure 3.\n\nSpot localization issues\n------------------------\n\nPseudolocales provide a time-saving and effective way to spot potential\nlocalizability issues in the UI by helping you identify problems in the\nfollowing areas:\n\n- Hardcoded strings, which can't be sent to translation, display as unaccented text in the pseudolocale to make them noticeable.\n- UI layout issues caused by text expansion, showing where the UI can break due to text length.\n- String concatenation, which displays as one message split across two or\n more brackets. This can make correct translation difficult, because translators\n have to translate each part independently without knowing that the parts\n are related. String concatenation can also make correct translation impossible,\n because different\n languages might require a different order of parts or a completely different\n sentence structure. For example, languages such as Japanese, Korean, and\n Tamil place the verb at the end of a sentence. When a sentence is concatenated,\n translators can't change the word order as needed.\n\n- Bidirectional (BIDI) text problems, such as when content in one text\n direction\n includes an inline phrase in the opposite text direction, making the string\n difficult to read.\n\n- Right-to-left (RTL) problems, such as elements not being mirrored. Some examples are\n a UI element not moving to the left, text not reversing and moving to the\n left, or misplaced punctuation, such as \"pseudolocales rule!\" changing to\n \"elur selacoloduesp!\" instead of \"!elur selacoloduesp\"."]]