Skip to main content

lensbench_core/
i18n.rs

1//! Message language. Messages are written in English; a Japanese translation is shown
2//! when the language is Japanese.
3//!
4//! - Language: [`set_lang`] (the GUI setting), otherwise `LENSBENCH_LANG` (`ja`・`en`), otherwise the OS language
5//!   (Japanese if it starts with `ja`, English otherwise).
6//! - Translation: a table (the computing crates' one is `lang/ja.tsv` of the `lensbench-lang` crate, which the entry
7//!   points add with [`add_table`] at start-up; it is kept out of this crate so that adding a line does not rebuild
8//!   every crate that depends on the core) holds `English template<TAB>Japanese template`. A `{...}` in the English
9//!   template matches any text, and the same `{...}` in the Japanese template is replaced by that text
10//!   (identical tokens such as `{}` are taken in order). Only the text slots `{e}` (a nested message),
11//!   `{why}`・`{hint}` (an added note) and `{what}` (a label) are translated again; other slot values (names,
12//!   numbers, file names) are kept as they are. Only `{e}` and `{why}` may hold `": "`. When several lines match, the one with the most
13//!   literal text wins. A message that is not in the table is split at
14//!   `": "` and each part is translated (the context added by [`crate::Error::at`]); text with no match stays as is.
15//! - New messages: write them in English and add the Japanese line to `lensbench-lang/lang/ja.tsv`. Crates outside
16//!   this repository's public part keep their own table and add it with [`add_table`].
17
18use std::collections::HashMap;
19use std::sync::atomic::{AtomicU8, Ordering};
20use std::sync::{OnceLock, RwLock};
21
22/// Message language
23#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24pub enum Lang {
25    /// English (the language the messages are written in)
26    En,
27    /// Japanese (from the tables added with [`add_table`])
28    Ja,
29}
30
31/// 0: not decided yet, 1: English, 2: Japanese
32static LANG: AtomicU8 = AtomicU8::new(0);
33
34/// Choose the message language (the GUI calls this when its language changes)
35pub fn set_lang(l: Lang) {
36    LANG.store(if l == Lang::Ja { 2 } else { 1 }, Ordering::Relaxed);
37}
38
39#[cfg(not(target_arch = "wasm32"))]
40fn os_locale() -> String {
41    sys_locale::get_locale().unwrap_or_default()
42}
43
44/// On wasm the GUI chooses the language with [`set_lang`]
45#[cfg(target_arch = "wasm32")]
46fn os_locale() -> String {
47    String::new()
48}
49
50/// Language from `LENSBENCH_LANG`, otherwise the OS language
51fn detect() -> Lang {
52    let env = std::env::var("LENSBENCH_LANG").unwrap_or_default();
53    let s = if env.trim().is_empty() {
54        os_locale()
55    } else {
56        env
57    };
58    if s.trim().to_lowercase().starts_with("ja") {
59        Lang::Ja
60    } else {
61        Lang::En
62    }
63}
64
65/// The current message language
66pub fn lang() -> Lang {
67    match LANG.load(Ordering::Relaxed) {
68        1 => Lang::En,
69        2 => Lang::Ja,
70        _ => {
71            let l = detect();
72            set_lang(l);
73            l
74        }
75    }
76}
77
78/// Whether messages are shown in Japanese
79pub fn is_ja() -> bool {
80    lang() == Lang::Ja
81}
82
83/// One piece of a template: literal text or a `{...}` slot
84#[derive(Debug, Clone, PartialEq)]
85enum Piece<'a> {
86    Text(&'a str),
87    Slot(&'a str),
88}
89
90/// The pieces of a template (slices of the template: the tables are read at each start, so no copies)
91fn pieces(t: &str) -> Vec<Piece<'_>> {
92    let mut out = Vec::new();
93    let mut rest = t;
94    while let Some(a) = rest.find('{') {
95        let Some(b) = rest[a..].find('}').map(|b| a + b) else {
96            break;
97        };
98        if a > 0 {
99            out.push(Piece::Text(&rest[..a]));
100        }
101        out.push(Piece::Slot(&rest[a..=b]));
102        rest = &rest[b + 1..];
103    }
104    if !rest.is_empty() {
105        out.push(Piece::Text(rest));
106    }
107    out
108}
109
110#[derive(Clone)]
111struct Entry {
112    en: Vec<Piece<'static>>,
113    ja: Vec<Piece<'static>>,
114}
115
116/// The computing crates' table, for the tests of this crate (the program adds it with `lensbench_lang::register`)
117#[cfg(test)]
118const JA: &str = include_str!("../../lensbench-lang/lang/ja.tsv");
119
120/// The tables before any [`add_table`]: none in the program, the computing crates' table in the tests of this crate
121#[cfg(test)]
122fn initial() -> Vec<&'static str> {
123    vec![JA]
124}
125
126#[cfg(not(test))]
127fn initial() -> Vec<&'static str> {
128    Vec::new()
129}
130
131/// The table lines with a tab: `(in an "# items" section, English, Japanese)`. Lines of an `# items` section are names
132/// (tolerance items such as `{name} decenter x`) that only [`translate_item`] uses: their templates
133/// match any head, so they must not take part of a message
134fn table_lines(text: &str) -> impl Iterator<Item = (bool, &str, &str)> + '_ {
135    let mut items = false;
136    text.lines().filter_map(move |l| {
137        if l.starts_with('#') {
138            items = l.starts_with("# items");
139            return None;
140        }
141        let (en, ja) = l.split_once('\t')?;
142        (!l.trim().is_empty()).then_some((items, en, ja))
143    })
144}
145
146fn entries(text: &'static str, items: bool) -> impl Iterator<Item = Entry> {
147    table_lines(text)
148        .filter(move |(i, _, _)| *i == items)
149        .map(|(_, en, ja)| Entry {
150            en: pieces(en),
151            ja: pieces(ja),
152        })
153}
154
155/// One kind of table built from the tables added with [`add_table`]. A text is read the
156/// first time this kind is used (`pending` until then), so a start in English, or one that shows no
157/// message, does not parse the tables
158struct Lazy<T> {
159    built: T,
160    /// Texts added but not read yet, in the order they were added
161    pending: Vec<&'static str>,
162    read: fn(&mut T, &'static str),
163}
164
165impl<T> Lazy<T> {
166    fn new(built: T, read: fn(&mut T, &'static str)) -> RwLock<Self> {
167        RwLock::new(Lazy {
168            built,
169            pending: initial(),
170            read,
171        })
172    }
173}
174
175/// The table with every added text read
176fn get<T>(l: &'static RwLock<Lazy<T>>) -> std::sync::RwLockReadGuard<'static, Lazy<T>> {
177    let t = l.read().unwrap_or_else(|e| e.into_inner());
178    if t.pending.is_empty() {
179        return t;
180    }
181    drop(t);
182    {
183        let mut w = l.write().unwrap_or_else(|e| e.into_inner());
184        let w = &mut *w;
185        for text in std::mem::take(&mut w.pending) {
186            (w.read)(&mut w.built, text);
187        }
188    }
189    l.read().unwrap_or_else(|e| e.into_inner())
190}
191
192type Entries = RwLock<Lazy<Vec<Entry>>>;
193
194/// Message templates
195fn table() -> &'static Entries {
196    static T: OnceLock<Entries> = OnceLock::new();
197    T.get_or_init(|| Lazy::new(Vec::new(), |v, t| v.extend(entries(t, false))))
198}
199
200/// The names of the `# items` sections ([`translate_item`])
201fn item_table() -> &'static Entries {
202    static T: OnceLock<Entries> = OnceLock::new();
203    T.get_or_init(|| Lazy::new(Vec::new(), |v, t| v.extend(entries(t, true))))
204}
205
206type Lines = RwLock<Lazy<HashMap<&'static str, &'static str>>>;
207
208/// The table by whole English line for [`translate_doc`] (later lines win). The help of every command is
209/// translated at each start, so this is a hash lookup rather than a pass over the templates
210fn whole_lines() -> &'static Lines {
211    static T: OnceLock<Lines> = OnceLock::new();
212    T.get_or_init(|| Lazy::new(HashMap::new(), |m, t| m.extend(lines(t))))
213}
214
215/// Add a table of the same format as `lensbench-lang/lang/ja.tsv` (the entry points add that table, and an exe
216/// that adds plugins adds the Japanese of their messages, at start-up; the text is read when it is first needed). Check it with [`check_table`] in a test
217pub fn add_table(text: &'static str) {
218    fn add<T>(l: &RwLock<Lazy<T>>, text: &'static str) {
219        l.write()
220            .unwrap_or_else(|e| e.into_inner())
221            .pending
222            .push(text);
223    }
224    add(table(), text);
225    add(item_table(), text);
226    add(whole_lines(), text);
227}
228
229fn lines(text: &'static str) -> impl Iterator<Item = (&'static str, &'static str)> {
230    table_lines(text)
231        .filter(|(i, _, _)| !i)
232        .map(|(_, en, ja)| (en, ja))
233}
234
235/// Check a table: each line has a tab, the same `{…}` in English and Japanese, unnamed `{}` in the same
236/// order, no two slots side by side, and no English twice. The errors name the line
237pub fn check_table(text: &str) -> Result<(), String> {
238    let mut seen = std::collections::HashMap::new();
239    for (n, l) in text.lines().enumerate() {
240        if l.trim().is_empty() || l.starts_with('#') {
241            continue;
242        }
243        let at = |m: &str| format!("line {}: {m}: {l}", n + 1);
244        let (en, ja) = l.split_once('\t').ok_or_else(|| at("no tab"))?;
245        if let Some(k) = seen.insert(en, n + 1) {
246            return Err(at(&format!("the same English as line {k}")));
247        }
248        let slots = |t: &str, unnamed: bool| {
249            let mut v: Vec<String> = pieces(t)
250                .into_iter()
251                .filter_map(|p| match p {
252                    Piece::Slot(s) if !unnamed || s == "{}" || s.starts_with("{:") => {
253                        Some(s.to_string())
254                    }
255                    _ => None,
256                })
257                .collect();
258            if !unnamed {
259                v.sort();
260            }
261            v
262        };
263        if slots(en, false) != slots(ja, false) {
264            return Err(at("different slots"));
265        }
266        // 名前の無い {}・{:..} は引数の順に埋まるので、英語と日本語で順を変えない
267        if slots(en, true) != slots(ja, true) {
268            return Err(at("unnamed slots in a different order"));
269        }
270        if pieces(en)
271            .windows(2)
272            .any(|w| matches!(w, [Piece::Slot(_), Piece::Slot(_)]))
273        {
274            return Err(at("two slots side by side can't be matched"));
275        }
276    }
277    Ok(())
278}
279
280/// Match `s` against the pieces `p` (anchored at both ends); the slots' text in order
281fn matches(p: &[Piece], s: &str) -> Option<Vec<String>> {
282    matches_at(p, s, false)
283}
284
285/// [`matches`]; `open` is whether the text just before ends with "("
286fn matches_at(p: &[Piece], s: &str, open: bool) -> Option<Vec<String>> {
287    match p.split_first() {
288        None => s.is_empty().then(Vec::new),
289        Some((Piece::Text(t), rest)) => matches_at(rest, s.strip_prefix(*t)?, t.ends_with('(')),
290        Some((Piece::Slot(name), rest)) => {
291            // shortest slot text first; a slot never takes an empty string, except a whole
292            // parenthesis "({})" (an empty list: "no state x ()")
293            let next = match rest.first() {
294                Some(Piece::Text(t)) => Some(*t),
295                _ => None,
296            };
297            let empty = open && next.is_some_and(|t| t.starts_with(')'));
298            let ends: Vec<usize> = match next {
299                Some(t) => s
300                    .match_indices(t)
301                    .map(|(i, _)| i)
302                    .filter(|&i| i > 0 || empty)
303                    .collect(),
304                None if rest.is_empty() => vec![s.len()],
305                None => s.char_indices().map(|(i, _)| i).skip(1).collect(),
306            };
307            // 値の欄は「: 」を跨がない(跨ぐのは入れ子の誤り {e} と添え書き {why} だけ。「surface 3: cancelled」は「surface {}」に
308            // 当てず、「: 」で分けて訳す)
309            let nested = *name == "{e}" || *name == "{why}";
310            // ラベルの欄({what}・{hint})は句(「incidence angle」)が入るので長い方から。ほかは短い方から
311            let mut ends = ends;
312            if matches!(name.to_ascii_lowercase().as_str(), "{what}" | "{hint}") {
313                ends.reverse();
314            }
315            ends.into_iter()
316                .filter(|&i| {
317                    let colon =
318                        s[..i].contains(": ") || (s[..i].ends_with(':') && s[i..].starts_with(' '));
319                    (i > 0 || empty) && (nested || !colon)
320                })
321                .find_map(|i| {
322                    let mut v = matches_at(rest, &s[i..], false)?;
323                    v.insert(0, s[..i].to_string());
324                    Some(v)
325                })
326        }
327    }
328}
329
330/// A slot whose text is itself a message to translate: `{e}`, `{why}`, `{hint}`, `{what}` (any case)
331fn is_text_slot(s: &str) -> bool {
332    matches!(
333        s.to_ascii_lowercase().as_str(),
334        "{e}" | "{why}" | "{hint}" | "{what}"
335    )
336}
337
338/// Fill the Japanese template with the slot texts (by slot token, in order for repeated tokens)
339fn fill(e: &Entry, vals: Vec<String>) -> String {
340    let slots: Vec<&&str> =
341        e.en.iter()
342            .filter_map(|p| match p {
343                Piece::Slot(s) => Some(s),
344                Piece::Text(_) => None,
345            })
346            .collect();
347    let mut used = vec![false; vals.len()];
348    let mut out = String::new();
349    for p in &e.ja {
350        match p {
351            Piece::Text(t) => out.push_str(t),
352            Piece::Slot(s) => {
353                let i = slots
354                    .iter()
355                    .enumerate()
356                    .position(|(i, x)| *x == s && !used[i])
357                    .or_else(|| slots.iter().position(|x| *x == s));
358                match i {
359                    Some(i) => {
360                        used[i] = true;
361                        // 文の欄(`{e}`・`{why}`・`{hint}`・`{what}`)だけ訳す。名前・数などの値はそのまま
362                        // (ファイル名「surface 3.zmx」を「面 3.zmx」にしない)
363                        if is_text_slot(s) {
364                            out.push_str(&translate(&vals[i]));
365                        } else {
366                            out.push_str(&vals[i]);
367                        }
368                    }
369                    None => out.push_str(s),
370                }
371            }
372        }
373    }
374    out
375}
376
377/// Literal text length of a template (a longer one is more specific)
378fn literal_len(p: &[Piece]) -> usize {
379    p.iter()
380        .map(|x| match x {
381            Piece::Text(t) => t.len(),
382            Piece::Slot(_) => 0,
383        })
384        .sum()
385}
386
387/// Translate one English message into Japanese with the table (None if no entry matches). When several
388/// entries match, the one with the most literal text wins (`input {}` loses to `input {key} must be …`)
389fn lookup(s: &str) -> Option<String> {
390    lookup_in(table(), s)
391}
392
393/// The best entry of table `t` for `s`, filled. The lock is released before filling: [`fill`] translates the
394/// text slots again ([`translate`]), and a nested read while another thread waits to write (the first use of a
395/// table reads the added texts) would wait for ever
396fn lookup_in(t: &'static Entries, s: &str) -> Option<String> {
397    let (e, v) = {
398        let t = get(t);
399        t.built
400            .iter()
401            .filter_map(|e| matches(&e.en, s).map(|v| (literal_len(&e.en), e, v)))
402            .max_by_key(|(n, _, _)| *n)
403            .map(|(_, e, v)| (e.clone(), v))?
404    };
405    Some(fill(&e, v))
406}
407
408/// The Japanese of an English message (the whole message, otherwise each `": "`-separated part,
409/// otherwise, when every sentence has a line, each sentence: a note of several sentences joined by `". "`
410/// becomes sentences joined by "。")
411pub fn translate(s: &str) -> String {
412    if let Some(t) = lookup(s) {
413        return t;
414    }
415    match s.split_once(": ") {
416        Some((a, b)) => format!("{}: {}", translate(a), translate(b)),
417        // 文ごとに表の行があるときだけ(英語の文が混ざったまま「。」でつながない)
418        None if s.contains(". ") => s
419            .split(". ")
420            .map(lookup)
421            .collect::<Option<Vec<_>>>()
422            .map_or_else(|| s.to_string(), |v| v.join("。")),
423        None => s.to_string(),
424    }
425}
426
427/// The message in the current language (English as written, Japanese from the table)
428pub fn tr(s: &str) -> String {
429    if is_ja() {
430        translate(s)
431    } else {
432        s.to_string()
433    }
434}
435
436/// The Japanese of a line only when a table line is exactly that text (descriptions: an
437/// English text with no line of its own must not be taken apart by message templates such as `surface {}`)
438fn exact(s: &str) -> Option<String> {
439    get(whole_lines()).built.get(s).map(|j| j.to_string())
440}
441
442/// Japanese of a description of several lines (help, analysis settings): each line from its own table line
443/// (a trailing ` [unit]` is kept as it is); lines with no line of their own stay English
444pub fn translate_doc(s: &str) -> String {
445    let line = |l: &str| {
446        exact(l)
447            .or_else(|| {
448                let (a, u) = l.rsplit_once(" [").filter(|(_, u)| u.ends_with(']'))?;
449                exact(a).map(|j| format!("{j} [{u}"))
450            })
451            .unwrap_or_else(|| l.to_string())
452    };
453    s.split('\n').map(line).collect::<Vec<_>>().join("\n")
454}
455
456/// The Japanese of a name from an `# items` section of the table (a tolerance item such as
457/// `L1 group decenter x`); other text stays as it is
458pub fn translate_item(s: &str) -> String {
459    lookup_in(item_table(), s).unwrap_or_else(|| s.to_string())
460}
461
462/// [`translate_item`] in the current language
463pub fn tr_item(s: &str) -> String {
464    if is_ja() {
465        translate_item(s)
466    } else {
467        s.to_string()
468    }
469}
470
471/// [`translate_doc`] in the current language
472pub fn tr_doc(s: &str) -> String {
473    if is_ja() {
474        translate_doc(s)
475    } else {
476        s.to_string()
477    }
478}
479
480/// A warning line for the terminal: "warning: …" in English, "注意: …" (translated) in Japanese
481pub fn warning(w: impl AsRef<str>) -> String {
482    tr(&format!("warning: {e}", e = w.as_ref()))
483}
484
485#[cfg(test)]
486mod tests {
487    use super::*;
488
489    fn entry(en: &'static str, ja: &'static str) -> Entry {
490        Entry {
491            en: pieces(en),
492            ja: pieces(ja),
493        }
494    }
495
496    #[test]
497    fn templates_match_and_fill() {
498        let e = entry(
499            "glass {name} is not in the catalogs (surface {s})",
500            "硝材 {name} がカタログにありません(面 {s})",
501        );
502        let v = matches(&e.en, "glass N-SK16 is not in the catalogs (surface 1)").unwrap();
503        assert_eq!(fill(&e, v), "硝材 N-SK16 がカタログにありません(面 1)");
504        // repeated {} in order, reordered in Japanese by name is not possible, but order is kept
505        let e = entry("{} must be at most {}", "{} は {} 以下に");
506        let v = matches(&e.en, "rings must be at most 50").unwrap();
507        assert_eq!(fill(&e, v), "rings は 50 以下に");
508        assert!(matches(&e.en, "nothing").is_none());
509    }
510
511    #[test]
512    fn every_line_has_the_same_slots() {
513        check_table(JA).unwrap_or_else(|e| panic!("lang/ja.tsv {e}"));
514        assert!(check_table("a {} b {:.3}\tA {:.3} B {}").is_err());
515        assert!(check_table("a {}{}\tA {}{}").is_err());
516        assert!(check_table("a\tA\nb\tB\na\tA").is_err());
517    }
518
519    #[test]
520    fn docs_translate_only_whole_lines() {
521        // 表に行の無い英語の説明は誤りの文の型(`surface {}` など)で崩さない
522        assert_eq!(translate_doc("surface tilt"), "surface tilt");
523        assert_eq!(
524            translate_doc("Number of quadrature points\nno such line [mm]"),
525            "求積の点の数\nno such line [mm]"
526        );
527        assert_eq!(
528            translate_doc("Propagation distance [mm]"),
529            "伝搬の距離 [mm]"
530        );
531    }
532
533    #[test]
534    fn tolerance_item_names() {
535        assert_eq!(translate_item("L1 group decenter x"), "L1 群の偏心x");
536        assert_eq!(translate_item("L1 decenter x"), "L1 偏心x");
537        assert_eq!(translate_item("lens 2 thickness 3"), "lens 2 厚み3");
538        assert_eq!(translate_item("L1 R2"), "L1 R2");
539        // 項目名の型は誤りの文の経路では使わない(先頭が何でも当たるので)
540        assert_eq!(translate("no such glass index 3"), "no such glass index 3");
541    }
542
543    #[test]
544    fn notes_of_several_sentences() {
545        assert_eq!(
546            translate("the seat is the mount end (not known from the STEP). inner thread SM1 (for elements of diameter 25.4 mm)"),
547            "座の位置はマウントの端(STEP から分かりません)。内側のねじ SM1(入る光学素子の径 25.4 mm)"
548        );
549        // 訳の無い文が混ざれば英語のまま
550        let s = "the seat is the mount end (not known from the STEP). no such sentence";
551        assert_eq!(translate(s), s);
552        assert_eq!(
553            translate("outer diameter: catalog 30 mm, STEP 40.64 mm (difference 10.64 mm)"),
554            "外径: カタログ 30 mm、STEP 40.64 mm(差 10.64 mm)"
555        );
556    }
557
558    #[test]
559    fn swap_progress_eta_in_seconds() {
560        assert!(translate("screening 3/10 (5 s left)").ends_with("3/10(残り 5 秒)"));
561    }
562
563    #[test]
564    fn surface_label_coating_is_translated() {
565        assert_eq!(
566            translate("surface 3(STANDARD, N-BK7, coating AR, 「L1」)"),
567            "面 3(STANDARD, N-BK7, コーティング AR, 「L1」)"
568        );
569        assert_eq!(translate("surface 2(STANDARD)"), "面 2(STANDARD)");
570    }
571
572    #[test]
573    fn kinds_are_translated() {
574        assert_eq!(translate("cancelled"), "中断しました");
575        assert_eq!(
576            translate("surface 3: cancelled"),
577            "面 3: 中断しました",
578            "context parts are translated one by one"
579        );
580        // 埋めた値は訳さない(入れ子の誤り {e} だけ訳す)
581        assert_eq!(
582            translate("surface 3.zmx: no such file"),
583            "surface 3.zmx: ファイルがありません"
584        );
585        assert_eq!(translate("set 2: surface 3"), "組 2: 面 3");
586        // 表の行。短い型の「surface {}」より長い型が勝つ
587        assert_eq!(
588            translate("surface 3 can't be written (1 to 9)"),
589            "面 3 は書けません(1〜9)"
590        );
591        // 注意の行: 「注意: 」を付け、中の文も訳す
592        assert_eq!(
593            translate("warning: removed multi-configuration row 3.t"),
594            "注意: 多重構成の行 3.t を外しました"
595        );
596        // 札({what})も訳す: 「state 2」→「状態 2」
597        assert!(translate(
598            "state 2: 7.t differs from the loaded system (1, loaded system 2), so set is not applied"
599        )
600        .starts_with("状態 2: 7.t は"));
601        assert_eq!(
602            translate("lensbench run: a.py (Python: python3, threads 4)"),
603            "lensbench run: a.py(Python: python3、スレッド 4)"
604        );
605        // 空の一覧の括弧「()」は空の欄に当てる
606        assert_eq!(
607            translate("no state nosuch ()"),
608            "状態 nosuch はありません()"
609        );
610        assert_eq!(
611            translate("set 3: no wavelength 2 (1 to 1)"),
612            "組 3: 波長 2 はありません(1〜1)"
613        );
614        assert_eq!(
615            translate("the ray stopped (wavelength 1, pupil (0.000, 1.000), surface 4)"),
616            "光線が止まりました(波長 1、瞳 (0.000, 1.000)、面 4)"
617        );
618        // ラベルの欄 {what} に 2 語以上の句
619        assert_eq!(
620            translate("surface 3: Grid Sag grid columns 1 (an integer 2 to 16000000)"),
621            "面 3: Grid Sag のグリッドの列の数 1(2〜16000000 の整数)"
622        );
623        assert_eq!(
624            translate("number of zmx configurations MNUM 1.5 (an integer 1 to 1000)"),
625            "zmx の構成の数 MNUM 1.5(1〜1000 の整数)"
626        );
627        assert_eq!(
628            translate(
629                "coating table AR: incidence angle 95.0000 deg is outside the table range 0 to 89"
630            ),
631            "コーティングの表 AR: 入射角 95.0000 deg が表の範囲 0〜89 の外"
632        );
633    }
634}