SchoolPhysicalExamination/application/testapp/controller/Language.php

345 lines
31 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\testapp\controller;
class Language extends Base
{
// 支持的语言列表
protected $supportedLanguages = [
'en' => 'English',
'zh-Hans' => 'Chinese',
'es' => 'Spanish',
'fr' => 'French',
'pt' => 'Portuguese',
'ar' => 'Arabic',
'ru' => 'Russian',
'de' => 'German'
];
// $language_data = new Language();
// if(!$language_str['language']){
// $language_str['language'] = 'zh-Hans';
// }
// $result_end = $language_data->handling_languages_from_multiple_countries($language_str['language'], $result_end);
// 语言映射表
protected $languageMap = [
'en' => [
'操作成功' => 'Success',
'男' => 'Male',
'女' => 'Female',
'年龄' => 'Age',
'体重' => 'Weight',
'身高' => 'Height',
'消瘦' => 'Slim',
'正常' => 'Normal',
'偏重' => 'Overweight',
'肥胖' => 'Obesity',
'反映和衡量一个人健康状况的重要标志之一' => "One of the important indicators reflecting and measuring a person's health status",
'人体纵向部分的长度,源于人体的纵向生长,受遗传因素的影响较大' => "The length of the longitudinal part of the human body is derived from its longitudinal growth and is greatly influenced by genetic factors",
'BMI是身体质量指数,是目前国际上常用的衡量人体胖瘦程度以及是否健康的一个标准。' => "BMI is the body mass index, which is currently a commonly used international standard for measuring the degree of body fat, thinness, and health.",
'公斤' => "kg",
'CM' => "cm",
'岁' => " years,",
'个月' => " months",
'年' => "-",
'月' => "-",
'日' => "",
'身体得分' => "Physical score",
'分' => "score",
'身体类型' => "Body Type",
'健美肌肉型' => "Bodybuilding muscle type",
'低' => "Low",
'偏低' => "Slightly low",
'标准' => "Standard",
'偏高' => "Slightly high",
'高' => "High",
'矮' => "Short",
'偏矮' => "Slightly short",
// '脂肪率' => "Body Fat Percentage",
'脂肪率' => "Fat%",
'体脂率是指身体成分中,脂肪组织所占的比率。测量体脂率比单纯的只测量体重更能反映我们身体的脂肪水平(肥胖程度)。' => "Body fat percentage refers to the proportion of fat tissue in body composition. Measuring it provides a more accurate reflection of body fat levels (degree of obesity) than weight measurement alone.",
// '脂肪量' => "Fat Mass",
'脂肪量' => "Fat",
'人体脂肪的重量' => "Body Fat Weight",
// '肌肉率' => "Muscle Percentage",
'肌肉率' => "Muscle%",
'优' => "Excellent",
'根据人体肌肉总量和人体体重、身高等相结合得到的人体的一个比例值,这个值的范围决定一个人的身体健康状况以及力量的多少。' => "Muscle percentage is a ratio derived from total muscle mass, body weight, height, etc. Its range determines a person's health status and strength level.",
// '肌肉量' => "Muscle Mass",
'肌肉量' => "MM",
'不足' => "Insufficient",
'肌肉量=实际体重*肌肉率' => "Muscle Mass = Actual Weight × Muscle Percentage",
// '水分' => "Body Water",
'水分' => "TBW%",
'指人体内水分比例。' => "Refers to the proportion of water in the human body.",
// '蛋白量' => "Protein Mass",
'蛋白量' => "Protein Mass",
'蛋白量=实际体重*蛋白率' => "Protein Mass = Actual Weight × Protein Percentage",
// '骨重' => "Bone Mass",
'骨重' => "BMC",
'单位体积内,骨组织、骨矿物质(钙、磷等)和骨基质(骨胶原、蛋白率、无机盐等等)含量,骨量代表它们骨骼健康的情况。' => "Bone mass refers to the content of bone tissue, minerals (calcium, phosphorus, etc.), and bone matrix (collagen, proteins, inorganic salts, etc.) per unit volume, reflecting skeletal health.",
// '蛋白率' => "Protein Percentage",
'蛋白率' => "Protein%",
'人体内蛋白率含量。' => "The proportion of protein in the human body.",
// '基础代谢' => "Basal Metabolic Rate (BMR)",
'基础代谢' => "BMR",
'指人体在清醒而又极端安静的状态下,不受肌肉活动、环境温度、食物及精神紧张等影响时的能量代谢率' => "The energy expenditure rate when the body is awake, completely at rest, and unaffected by muscle activity, ambient temperature, food intake, or mental stress.",
// '内脏指数' => "Visceral Fat Index",
'内脏指数' => "VFL",
'警惕' => "Caution",
'危险' => "Danger",
// '内脏脂肪指数' => "Visceral Fat Level",
'内脏脂肪指数' => "VFI",
// '皮下脂肪' => "Subcutaneous Fat",
'皮下脂肪' => "SubQ Fat",
'皮下脂脂肪就是贮存于皮下的脂肪组织人体的脂肪大约有2/3贮存在皮下组织' => "Subcutaneous fat refers to adipose tissue stored under the skin. About two-thirds of body fat is stored subcutaneously.",
// '肥胖等级' => "Obesity Level",
'肥胖等级' => "Obesity Level",
'体重不足' => "Underweight",
'去脂体重' => "Lean Body Mass",
'体型' => "Body Type",
'体龄' => "Biological Age",
'肥胖的程度,表现实际体重与理想体重的差距。肥胖等级是判定肥胖症的一个指标。' => "Obesity level indicates the disparity between actual and ideal weight, serving as a diagnostic criterion for obesity.",
'孩子可能存在营养不良对于处在生长发育期的孩子而言蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、铁、维生素D、赖氨酸等营养。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => "The child may be malnourished: For growing children, protein, carbohydrates, vitamins, and minerals are critical. Ensure adequate intake of protein, zinc, calcium, iron, vitamin D, lysine, etc. Consider herbal foods like chicken gizzard-hawthorn paste to improve digestion and appetite.",
'坚持适当、科学的跳跃运动能够科学地增加学生体重,能够改善学 生体重过低的情况;同时运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。' => "Moderate, scientifically designed jumping exercises can help underweight students gain weight by boosting energy expenditure and gastrointestinal motility, thereby increasing appetite. Combined with balanced nutrition, this supports healthy weight gain.",
'孩子开始对于赞赏、鼓励、认同和肯定有需求,而且此阶段父亲在孩子的性格塑造、情绪控制以及责任感培养方面扮演着重要的角色,必须告诉孩子什么事应该做、什么事不应该做,并经常性地给孩子一些积极地暗示。例如,可以时常向孩子表达“我会一直在你身边,不要害怕””我对你的进步都看在眼里等类似的话语。' => 'Children begin developing needs for praise, encouragement, recognition and affirmation. During this phase, fathers play a vital role in character formation, emotional regulation and responsibility cultivation. Clearly communicate appropriate behaviors while providing consistent positive reinforcement, such as saying: "I\'ll always be here for you" or "I see your progress."',
'步入最佳学习期,除了文化课的学习更多的还有情绪调节、人际交往的学习,会模仿父母、老师同学。此阶段需要的不仅是尊重和信任,还需要更多自由选择的权利,变管制为引导。' => 'Entering the optimal learning period, children develop emotional regulation and social skills beyond academics, mimicking parents, teachers and peers. They require not just respect and trust, but also increased autonomy - transitioning from control to guidance.',
'该年龄段睡眠时间建议11-14小时' => 'Recommended sleep duration: 11-14 hours',
'0-1岁的孩子6个月之前多练习趴着、抬头、翻身等6个月后练习爬行8个月后可尝试坐着。充分的爬行运动有利于孩子协调性和平衡力的培养。' => '0-1 year olds: Practice tummy time, head lifting and rolling before 6 months; crawling after 6 months; attempt sitting at 8 months. Ample crawling enhances coordination and balance.',
'3-7岁的孩子骑两轮车、拍踢球、打篮球、游泳、爬山每天高强度运动不超过30分钟。' => '3-7 year olds: Bicycle riding, ball games, basketball, swimming, mountain climbing. Limit high-intensity exercise to 30 minutes daily.',
'正值青春期,生理的特点决定了情绪的跌宕起伏。当孩子出现情绪问题时,父母可以告诉孩子一些解决的办法,然后让他自行体悟和理解,教会孩子接纳情绪的方法而不是如何对抗情绪。' => 'Adolescents experience physiological mood fluctuations. When emotional issues arise, parents should teach coping strategies for self-discovery, emphasizing emotional acceptance over resistance.',
'该年龄段睡眠时间建议8-10小时' => 'Recommended sleep duration: 8-10 hours',
'睡眠时间建议晚上9点到凌晨1点、早上5点到7点是孩子生长激素分泌最多的时间段此时进入深度睡眠生长激素的分泌就会最大化建议处在生长发育期的孩子尽量在9点前睡觉。' => 'Optimal sleep window: 9pm-1am and 5-7am when growth hormone peaks. Maximize secretion through deep sleep. Growing children should sleep before 9pm.',
'1、情绪的不稳定影响了下丘脑及垂体系统的正常工作进而使垂体生长激素分泌减少长期的情绪障碍除了影响身高同时还会造成孩子智力增长慢、多动、人际关系不协调等异常现象。' => '1. Emotional instability disrupts hypothalamic-pituitary function, reducing growth hormone secretion. Chronic emotional issues may impair height development, cognitive growth, and cause hyperactivity or social maladjustment.',
'1-3岁的孩子此年龄段实现了由走到跑的转变神经系统也得到了发育。鼓励孩子有利于生长发育的活动即可踩图案、绕障碍行走、学小动物走路如青蛙跳、猴子跑、老虎匍匐前进等、仰卧起坐等。' => '1-3 year olds: Transitioning from walking to running with developing nervous systems. Encourage developmental activities: pattern stepping, obstacle courses, animal walks (frog jumps, monkey runs, tiger crawls), and sit-ups.',
'该年龄段睡眠时间建议14-17小时' => 'Recommended sleep duration: 14-17 hours',
'该年龄段睡眠时间建议10-13小时' => 'Recommended sleep duration: 10-13 hours',
'该年龄段睡眠时间建议12-15小时' => 'Recommended sleep duration: 12-15 hours',
'除了满足食物等生理需求,需要建立足够的安全感,充分陪伴、呵护。还要在排除一些安全隐患后适当满足孩子的探索需求。' => 'Beyond physiological needs like food, provide security through attentive care while enabling safe exploration after risk assessment.',
'该年龄段睡眠时间建议9-11小时' => 'Recommended sleep duration: 9-11 hours',
'8-16岁的孩子1、每周3-5次跳绳50-100次左右/组每天做5组每组间隔5分钟2、立定跳远每周5-7次每次20-50次3、慢跑500-1000米3、20个俯卧撑30个上下蹲、30个仰卧起坐。' => '8-16 year olds: 1) Rope skipping 3-5x/week: 5 sets of 50-100 skips daily with 5-minute intervals; 2) Standing long jumps 5-7x/week (20-50 reps); 3) Jogging 500-1000m; 4) 20 push-ups, 30 squats, 30 sit-ups.',
'这个阶段的孩子最调皮,一方面非常依赖父母,另一方面又相对独立。这个阶段仍然需要安全感,并且父母本身的心理状态对孩子的影响依然深远,当他们情绪不稳定,孩子也极有可能受到影响。' => 'Children at this stage exhibit mischievousness while balancing dependence and independence. They still require security, and parental emotional stability profoundly impacts them - children often mirror parental emotional turbulence.',
'孩子可能存在营养不良对于处在生长发育期的孩子而言蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、铁、维生素D、赖氨酸等营养。' => 'The child may be malnourished: For growing children, four key nutrients - proteins, carbohydrates, vitamins and minerals - are crucial. Recommend supplementing adequate protein, zinc, calcium, iron, vitamin D, and lysine.',
'孩子可能存在营养不良对于处在生长发育期的孩子而言最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => 'The child may be malnourished: The most height-beneficial nutrients for growing children are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine.',
'对于处在生长发育期的孩子而言最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养预防营养不良。' => 'For growing children, the most height-promoting nutrients are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine to prevent malnutrition.',
'超重的孩子如不加以控制,则极易向肥胖转变。超重的孩子饮食注意事项:控制食量,吃八分饱;三餐规律,避免暴饮暴食;细嚼慢咽;营养均衡搭配,拒绝高油、高盐、高糖的食物,养成清淡的口味。' => 'Overweight children easily progress to obesity without intervention. Dietary guidelines: 80% fullness; regular meals; thorough chewing; balanced nutrition; avoiding greasy/salty/sugary foods; developing light tastes.',
'孩子可能存在中度营养不良对于处在生长发育期的孩子而言最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => 'The child may have moderate malnutrition: The most height-beneficial nutrients are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine.',
'孩子可能存在重度营养不良对于处在生长发育期的孩子而言最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养。' => 'The child may have severe malnutrition: The most height-beneficial nutrients are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine.',
'1、肥胖在某种意义来说是隐性的营养不良由于摄入热量过高孩子虽然看着胖但营养的摄入是不均衡的尤其对于8-14岁的孩子来说肥胖会极大地提高性早熟的概率。肥胖的孩子过度进食甜食、油腻的食物极易出现血糖高、高脂血症从而影响生长激素的分泌影响终身高。肥胖的孩子更容易缺乏维生素D影响骨骼的钙化和成长。2、肥胖的孩子饮食注意事项控制食量吃八分饱三餐规律避免暴饮暴食细嚼慢咽营养均衡搭配拒绝高油、高盐、高糖的食物养成清淡的口味。' => '1. Obesity represents hidden malnutrition - while calorie intake is excessive, nutrition remains unbalanced. Particularly for 8-14 year olds, obesity significantly increases precocious puberty risks. Overconsumption of sweets/greasy foods elevates blood sugar/lipids, impairing growth hormone secretion and final height. Obese children also face higher vitamin D deficiency risks, affecting bone calcification. 2. Dietary guidelines: 80% fullness; regular meals; thorough chewing; balanced nutrition; avoiding greasy/salty/sugary foods; developing light tastes.',
'对于处在生长发育期的孩子而言蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、铁、钙、维生素D、赖氨酸等营养预防营养不良造成体型偏瘦。' => 'For growing children, four key nutrients - proteins, carbohydrates, vitamins and minerals - are essential. Recommend supplementing adequate protein, zinc, iron, calcium, vitamin D, and lysine to prevent underweight malnutrition.',
'超重或肥胖的孩子如不加以控制,则极易向肥胖转变。超重或肥胖的孩子饮食注意事项:控制食量,吃八分饱;三餐规律,避免暴饮暴食;细嚼慢咽;营养均衡搭配,拒绝高油、高盐、高糖的食物,养成清淡的口味。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => 'Overweight/obese children easily progress to worse obesity without control. Dietary guidelines: 80% fullness; regular meals; thorough chewing; balanced nutrition; avoiding greasy/salty/sugary foods; developing light tastes. Recommend supplementing with chicken gizzard-hawthorn paste (a food-grade herbal digestant).',
'对于处在生长发育期的孩子而言蛋白质、碳水化合物、维生素和矿物质这四类营养素非常重要。建议补充足够的蛋白质、锌、钙、维生素D、赖氨酸等营养预防营养不良造成体型偏瘦。建议补充含鸡内金山楂膏健脾开胃类药食同源食物。' => 'For growing children, four key nutrients - proteins, carbohydrates, vitamins and minerals - are essential. Recommend supplementing adequate protein, zinc, calcium, vitamin D, and lysine to prevent underweight malnutrition, along with chicken gizzard-hawthorn paste (a food-grade herbal digestant).',
'对于处在生长发育期的孩子而言最有利于长高的营养素是蛋白质、碳水化合物、维生素和矿物质四类。建议补充足够的蛋白质、锌、钙、维生素D、赖氨酸等营养预防营养不良。铁' => 'For growing children, the most height-promoting nutrients are proteins, carbohydrates, vitamins and minerals. Recommend supplementing adequate protein, zinc, calcium, vitamin D, and lysine to prevent malnutrition. Iron.',
'运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。'=> 'Physical activity burns calories and enhances gastrointestinal motility, significantly stimulating children\'s appetite. When combined with balanced nutrition, this effectively supports healthy weight gain.',
'体育运动可以有效刺激骨骼与全身关节,从而促进生长激素分泌,加速软骨细胞分裂,从而促进了身高的增长。跳绳运动是一项非常健康的运动方式,可以促进青少年的骨骼生长和发育,促进青少年的体质健康。' => 'Exercise actively stimulates bones and joints throughout the body, promoting growth hormone secretion and accelerating chondrocyte division to facilitate height increase. Rope skipping is an exceptionally beneficial exercise that enhances adolescents\' bone development and overall physical fitness.',
'适宜的运动,能促进全身及骨的钙磷代谢,促进骨生长,长期的户外运动,加速骨细胞的生长,使管状骨变长,横径增粗,促进生长发育。'=> 'Moderate exercise optimizes whole-body calcium-phosphorus metabolism and bone growth. Regular outdoor activities accelerate osteocyte proliferation, lengthening long bones while increasing their diameter to promote healthy development.',
'运动会消耗能量培养运动习惯减少静坐时间建议每天参加体育运动的时间至少30分钟不贪睡睡得越久人体代谢速度就会越慢极易囤积脂肪。'=> 'Exercise consumes energy, establishes active habits and reduces sedentary behavior. We recommend minimum 30 minutes of daily physical activity. Excessive sleep slows metabolic rate and promotes fat accumulation.',
'体育运动可以有效刺激骨骼与全身关节,从而促进生长激素分泌,加速软骨细胞分裂,从而促进了身高的增长。长期科学地坚持跳绳,可以在很大程度上增加骨强度和骨密度,促进骨生长,从而改善青少年的骨健康情况。跳绳运动是一项非常健康的运动方式,可以促进青少年的骨骼生长和发育,促进青少年的体质健康。' => 'Physical training effectively activates skeletal and articular systems, boosting growth hormone production and chondrocyte multiplication to enhance height. Scientifically-guided long-term rope skipping significantly improves bone mineral density and strength, optimizing adolescents\' skeletal health. This exercise is particularly effective for promoting bone development and physical conditioning.',
'体育运动可以有效刺激骨骼与全身关节,从而促进生长激素分泌,加速软骨细胞分裂,从而促进了身高的增长。补救身高的最好方式就是长期坚持适当的体育运动,只要是采取科学的锻炼方法,都能促进骨骼的生长。在所有的运动项目中,全身运动、动力性跳跃运动和伸展运动这三类运动最能够促进身高增长。' => 'Exercise stimulates osseous and joint systems to enhance growth hormone release and cartilage cell division, facilitating height development. The most effective height-correction method involves sustained, moderate physical activity - any scientifically-designed regimen promotes bone growth. Among all exercises, full-body movements, plyometric jumps and stretching prove most beneficial for height improvement.',
'运动会消耗能量会增加体内脂肪的消耗减少储存量起到帮助控制体重的作用培养运动习惯减少静坐时间建议每天参加体育运动的时间至少30分钟不贪睡睡得越久人体代谢速度就会越慢极易囤积脂肪。' => 'Physical exertion increases calorie expenditure and fat utilization while reducing adipose storage, effectively aiding weight management. Establish consistent exercise routines and minimize inactivity with at least 30 minutes daily movement. Prolonged sleep decreases metabolic efficiency and encourages fat deposition.',
'运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子维持合格的体重。' => 'Exercise burns calories and stimulates digestive peristalsis, markedly improving children\'s appetite. Paired with nutritional balance, this helps maintain optimal body weight parameters.',
'建议多做跳跃运动立定跳远跳绳中跳跃刺激的频率以及速度都对于机体中过多脂肪的消耗起到促进作用能够一定程度上起到预防和控制肥胖、降低体重的作用同时培养运动习惯减少静坐时间建议每天参加体育运动的时间至少30分钟不贪睡睡得越久人体代谢速度就会越慢极易囤积脂肪。' => 'Prioritize jumping exercises (standing broad jumps, rope skipping) as their impact frequency and velocity significantly enhance fat oxidation, effectively preventing obesity and aiding weight control. Cultivate regular workout habits and limit sedentary periods to minimum 30 minutes daily activity. Excessive sleep duration reduces metabolic rate and promotes lipid accumulation.',
'运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子维持合格的体重。' => 'Physical activity expends energy and intensifies gastrointestinal motility, substantially boosting children\'s appetite. Combined with balanced nutrition, this assists in maintaining healthy weight standards.',
'体育运动可以有效刺激骨骼与全身关节,从而促进生长激素分泌,加速软骨细胞分裂,从而促进了身高的增长。' => 'Systematic exercise effectively activates skeletal and articular systems, stimulating growth hormone secretion and accelerating cartilage cell proliferation to optimize height development.',
'坚持适当、科学的跳跃运动能够科学地增加学生体重,能够改善学生体重过低的情况;同时运动会消耗能量并加速胃肠蠕动,这会使孩子的食欲大开,再配合均衡的营养有利于孩子增重。' => 'Consistent, properly-designed jumping exercises can scientifically increase students\' body mass and correct underweight conditions. Concurrently, physical training consumes energy and enhances digestive motility, stimulating appetite which - when supported by nutritional balance - promotes healthy weight gain.',
'《中华人民共和国卫生行业标准WS/T 423-2022》' => "《Chinese Health Industry Standard WS 423-2013》",
'《中华人民共和国卫生行业标准WS/T 612-2018》' => "《Chinese Health Industry Standard WS/T 612-2018》",
'《中华人民共和国卫生行业标准WS/T 586-2018》' => "《Chinese Health Industry Standard WS/T 1586-2018》",
'《WHO 5~19岁身高/体重判定标准》' => "《WHO Growth Reference for Children and Adolescents (519 Years)》",
// '头围' => "Head Circumference",
'头围' => "HC",
'头围是指绕头部一周的最大长度,头围的大小与脑的发育密切相关' => "Head circumference refers to the maximum length around the head. Its measurement is closely related to brain development.",
'跳绳数量或者分钟、秒钟值必须为整数' => 'The number of jump ropes, minutes, or seconds must be integers.',
'跳绳数不能小于等于0' => 'The jump rope count cannot be less than or equal to 0.',
'秒钟值不能大于60' => 'The seconds value cannot exceed 60.',
'跳绳个数(个)' => 'Jump rope count (times)',
'跳绳时长(分钟)' => 'Jump rope duration (minutes)',
'消耗卡路里(kcal)' => 'Calories burned (kcal)',
'个数' => 'Count',
'时长' => 'Duration',
'卡路里' => 'Calories',
'第一次' => 'First try',
'第二次' => 'Second try',
'第三次' => 'Third try',
'三次平均' => 'Average of three',
'最后成绩' => 'Final score',
'分' => 'Score',
'平均' => 'Average',
'成绩' => 'Score',
'时间(天)' => 'Time (days)',
'增重(kg)' => 'Weight gain (kg)',
'减脂(kg)' => 'Fat loss (kg)',
'数据变化' => 'Data changes',
'趋势' => 'Trend',
'之前' => 'Before',
'之后' => 'After',
'异常' => 'Abnormal',
'至' => 'To',
'无' => 'null',
],
// 可以添加更多语言映射
];
/**
* 处理多国语言翻译
*
* @param string $language 目标语言代码
* @param mixed $data 要翻译的数据(字符串或数组)
* @return mixed 翻译后的数据
*/
public function handling_languages_from_multiple_countries($language, $data)
{
// dump($data);
// 验证语言是否支持
if (!$this->isLanguageSupported($language)) {
return $data;
}
// 如果是数组,递归处理每个元素
if (is_array($data)) {
// dump(2);
$data = $this->translateArray($language, $data);
return $data;
}
// 如果是字符串,直接翻译
if (is_string($data)) {
// dump(3);
return $this->translateString($language, $data);
}
// dump($data);
// 其他类型直接返回
return $data;
}
/**
* 检查语言是否支持
*
* @param string $language 语言代码
* @return bool
*/
protected function isLanguageSupported($language)
{
return isset($this->supportedLanguages[$language]);
}
/**
* 翻译数组
*
* @param string $language 目标语言
* @param array $array 要翻译的数组
* @return array 翻译后的数组
*/
protected function translateArray($language, array $array)
{
$result = [];
foreach ($array as $key => $value) {
// 保持键不变,只翻译值
$result[$key] = is_array($value)
? $this->translateArray($language, $value)
: $this->translateString($language, $value);
}
return $result;
}
/**
* 翻译字符串
*
* @param string $language 目标语言
* @param string $string 要翻译的字符串
* @return string 翻译后的字符串
*/
protected function translateString($language, $string)
{
// dump($string);
// 检查是否有该语言的映射表
if (!isset($this->languageMap[$language])) {
return $string;
}
// 检查是否有对应的翻译
return $this->languageMap[$language][$string] ?? $string;
}
/**
* 获取支持的语言列表
*
* @return array
*/
public function getSupportedLanguages()
{
return $this->supportedLanguages;
}
/**
* 添加新的语言翻译
*
* @param string $language 语言代码
* @param array $translations 翻译映射数组
* @return bool
*/
public function addTranslations($language, array $translations)
{
if (!$this->isLanguageSupported($language)) {
return false;
}
if (!isset($this->languageMap[$language])) {
$this->languageMap[$language] = [];
}
$this->languageMap[$language] = array_merge(
$this->languageMap[$language],
$translations
);
return true;
}
}