te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>Localization for javascript confirmation buttons - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Localization for javascript confirmation buttons - Stack Overflow

programmeradmin4浏览0评论

I am working with Confirm box in javascript. For all browsers i found that when change the language of the browser, the confirmation button language in Confirm box doesn't change. I tested on chrome, firefox by changing the language to french. But the buttons label is not translated. Label of "OK" and "Cancel" doesn't change to other language.

Please Note : I am trying to see the localized string on confirmation box.

I am working with Confirm box in javascript. For all browsers i found that when change the language of the browser, the confirmation button language in Confirm box doesn't change. I tested on chrome, firefox by changing the language to french. But the buttons label is not translated. Label of "OK" and "Cancel" doesn't change to other language.

Please Note : I am trying to see the localized string on confirmation box.

Share Improve this question edited Dec 4, 2012 at 0:37 insomiac asked Dec 4, 2012 at 0:19 insomiacinsomiac 5,6648 gold badges47 silver badges73 bronze badges 6
  • 4 Localization is not an inherent feature in browsers, JavaScript, or the HTML specification. In other words, you need to manage localization on your own (usually detecting language on the server side and emitting the appropriate strings in the resulting HTML). Are you doing something specific where this expectation is met? If so, provide more details so we can help. – moribvndvs Commented Dec 4, 2012 at 0:26
  • I need to see the labels "OK" and "Cancel" translated into other language. I read this question stackoverflow./questions/1901745/… but this doesnt work for me. – insomiac Commented Dec 4, 2012 at 0:29
  • 1 Ah, I see, a browser-generated dialog ala confirm or alert. – moribvndvs Commented Dec 4, 2012 at 0:34
  • Yes. I am talking about confirm dialog which is from javascript. In confirm box, I always see the confirmation buttons in english instead of the browser language. – insomiac Commented Dec 4, 2012 at 0:36
  • Worksforme. If I change the language setting of Chrome to German, I see "OK" and "Abbrechen". Where did you change it, did you restart Chrome? – Bergi Commented Dec 4, 2012 at 1:33
 |  Show 1 more ment

1 Answer 1

Reset to default 12

There is no way to use confirm() and alert() JavaScript functions and have reliable results. It simply depends on the language of web browser, that is the program, not your preferred language.
The preferred language is used to tell the web server what is your preference in reference to the web page language.

So how to localize the confirmation or message dialogs, you would ask?
Well, get rid of them. Instead, please use jQuery UI Dialog's modal confirmation and follow your regular localization method for JavaScript string resources.
It is the only way to have confirmation dialog's titles and buttons translated reliably to the language of your web application.

发布评论

评论列表(0)

  1. 暂无评论