tva
← Insights

Widget Flags: ทำไม ISO Country Code จึงดีกว่าชื่อที่ขึ้นอยู่กับ Locale

Bug นั้น subtle: iOS widget แสดงชื่อประเทศที่ถูกต้องในภาษาอังกฤษแต่แสดง flag ที่ผิดสำหรับผู้ใช้บาง locale การติดตาม root cause เปิดเผยสมมติฐานที่ลึกเกี่ยวกับ Locale.current และ Locale.identifier และว่าทำไม ISO 3166-1 alpha-2 country code เป็น single source of truth ที่ถูกต้องสำหรับ flag rendering

Bug

Widget ของเราแสดง flag ประเทศโดยใช้ emoji flag: Regional Indicator Symbol Letters ใน Unicode สร้าง flag emoji เมื่อจับคู่กัน 🇸🇬 มาจาก "S" + "G" ในรูปแบบ Regional Indicator

การ generate เริ่มต้นของเราใช้ Locale.current.regionCode ซึ่งดูสมเหตุสมผล แต่ regionCode ใน Swift ไม่เหมือนกันกับ ISO 3166-1 alpha-2 country code เสมอ: มัน return region identifier สำหรับ locale ปัจจุบัน ซึ่งสำหรับ locale บางตัวใน ISO 3166-1 ที่ deprecated หรือ alternate codes

บทความที่เกี่ยวข้อง

บทความที่เกี่ยวข้อง