Skip to content

A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.

Languages: the words of the pure rules go through Texts, with plurals, and the generator writes per-language resources

Claude97fcd8774651
diff --git a/android/app/src/main/kotlin/com/coucou/android/app/TextIds.kt b/android/app/src/main/kotlin/com/coucou/android/app/TextIds.kt
new file mode 100644
index 00000000..d31bc767
--- /dev/null
+++ b/android/app/src/main/kotlin/com/coucou/android/app/TextIds.kt
@@ -0,0 +1,433 @@
+// Generated by android/scripts/gen-strings.mjs. Do not edit.
+package com.coucou.android.app
+
+import com.coucou.android.R
+
+/** Every string and plural of the app by key, for core/Texts.kt (static references, so the shrinker keeps them). */
+internal object TextIds {
+ val strings: Map<String, Int> = mapOf(
+ "app_name" to R.string.app_name,
+ "about_credit" to R.string.about_credit,
+ "about_repo" to R.string.about_repo,
+ "licences_title" to R.string.licences_title,
+ "licences_intro" to R.string.licences_intro,
+ "about_assets" to R.string.about_assets,
+ "action_allow" to R.string.action_allow,
+ "action_deny" to R.string.action_deny,
+ "action_close" to R.string.action_close,
+ "widget_description" to R.string.widget_description,
+ "widget_glance_label" to R.string.widget_glance_label,
+ "widget_solo_label" to R.string.widget_solo_label,
+ "widget_list_label" to R.string.widget_list_label,
+ "widget_solo_description" to R.string.widget_solo_description,
+ "widget_list_description" to R.string.widget_list_description,
+ "widget_mochi_description" to R.string.widget_mochi_description,
+ "widget_badge_description" to R.string.widget_badge_description,
+ "widget_big_label" to R.string.widget_big_label,
+ "widget_big_description" to R.string.widget_big_description,
+ "widget_pill_label" to R.string.widget_pill_label,
+ "widget_pill_description" to R.string.widget_pill_description,
+ "widget_alert_label" to R.string.widget_alert_label,
+ "widget_alert_description" to R.string.widget_alert_description,
+ "widget_ring_label" to R.string.widget_ring_label,
+ "widget_ring_description" to R.string.widget_ring_description,
+ "widget_today_label" to R.string.widget_today_label,
+ "widget_today_description" to R.string.widget_today_description,
+ "widget_mood_label" to R.string.widget_mood_label,
+ "widget_mood_description" to R.string.widget_mood_description,
+ "widget_today_unit" to R.string.widget_today_unit,
+ "widget_usage_off" to R.string.widget_usage_off,
+ "widget_big_usage_off" to R.string.widget_big_usage_off,
+ "widget_big_usage_off_line" to R.string.widget_big_usage_off_line,
+ "widget_big_not_connected" to R.string.widget_big_not_connected,
+ "widget_ring_cd" to R.string.widget_ring_cd,
+ "widget_today_cd" to R.string.widget_today_cd,
+ "widget_pill_cd" to R.string.widget_pill_cd,
+ "widget_initial_title" to R.string.widget_initial_title,
+ "widget_initial_line" to R.string.widget_initial_line,
+ "widget_initial_count" to R.string.widget_initial_count,
+ "widget_btn_home" to R.string.widget_btn_home,
+ "widget_btn_chat" to R.string.widget_btn_chat,
+ "widget_btn_settings" to R.string.widget_btn_settings,
+ "widget_btn_recent" to R.string.widget_btn_recent,
+ "widget_btn_session" to R.string.widget_btn_session,
+ "widget_btn_pair" to R.string.widget_btn_pair,
+ "widget_btn_home_cd" to R.string.widget_btn_home_cd,
+ "widget_btn_chat_cd" to R.string.widget_btn_chat_cd,
+ "widget_btn_settings_cd" to R.string.widget_btn_settings_cd,
+ "widget_btn_recent_cd" to R.string.widget_btn_recent_cd,
+ "widget_btn_session_cd" to R.string.widget_btn_session_cd,
+ "widget_btn_pair_cd" to R.string.widget_btn_pair_cd,
+ "widget_sample_claude" to R.string.widget_sample_claude,
+ "widget_sample_claude_short" to R.string.widget_sample_claude_short,
+ "widget_sample_codex" to R.string.widget_sample_codex,
+ "widget_sample_gemini" to R.string.widget_sample_gemini,
+ "widget_sample_approval" to R.string.widget_sample_approval,
+ "widget_sample_working" to R.string.widget_sample_working,
+ "widget_sample_finished" to R.string.widget_sample_finished,
+ "widget_sample_header" to R.string.widget_sample_header,
+ "widget_sample_one" to R.string.widget_sample_one,
+ "widget_sample_two_waiting" to R.string.widget_sample_two_waiting,
+ "widget_sample_ring_pct" to R.string.widget_sample_ring_pct,
+ "widget_sample_ring_label" to R.string.widget_sample_ring_label,
+ "widget_sample_pct_a" to R.string.widget_sample_pct_a,
+ "widget_sample_pct_b" to R.string.widget_sample_pct_b,
+ "widget_sample_codex_week" to R.string.widget_sample_codex_week,
+ "widget_sample_today" to R.string.widget_sample_today,
+ "widget_sample_two_agents" to R.string.widget_sample_two_agents,
+ "widget_sample_thinking" to R.string.widget_sample_thinking,
+ "widget_sample_idle" to R.string.widget_sample_idle,
+ "widget_sample_waiting" to R.string.widget_sample_waiting,
+ "status_connected" to R.string.status_connected,
+ "status_connecting" to R.string.status_connecting,
+ "status_not_connected" to R.string.status_not_connected,
+ "demo_mode" to R.string.demo_mode,
+ "demo_try" to R.string.demo_try,
+ "pair_button" to R.string.pair_button,
+ "approval_title" to R.string.approval_title,
+ "action_unpair" to R.string.action_unpair,
+ "demo_leave" to R.string.demo_leave,
+ "gallery" to R.string.gallery,
+ "pair_paste_short" to R.string.pair_paste_short,
+ "pairing_headline" to R.string.pairing_headline,
+ "pairing_help" to R.string.pairing_help,
+ "pairing_credit" to R.string.pairing_credit,
+ "pairing_about" to R.string.pairing_about,
+ "paste_title" to R.string.paste_title,
+ "paste_hint" to R.string.paste_hint,
+ "approval_later" to R.string.approval_later,
+ "approval_wants" to R.string.approval_wants,
+ "approval_too_long" to R.string.approval_too_long,
+ "approval_on_computer" to R.string.approval_on_computer,
+ "approval_caution" to R.string.approval_caution,
+ "approval_show_cmd" to R.string.approval_show_cmd,
+ "approval_hide_cmd" to R.string.approval_hide_cmd,
+ "question_title" to R.string.question_title,
+ "question_body" to R.string.question_body,
+ "question_see_answer" to R.string.question_see_answer,
+ "question_position" to R.string.question_position,
+ "question_pick_many" to R.string.question_pick_many,
+ "question_next" to R.string.question_next,
+ "question_back" to R.string.question_back,
+ "question_send" to R.string.question_send,
+ "question_confirm_title" to R.string.question_confirm_title,
+ "question_sent" to R.string.question_sent,
+ "question_not_sent" to R.string.question_not_sent,
+ "question_see" to R.string.question_see,
+ "question_ok" to R.string.question_ok,
+ "home_running" to R.string.home_running,
+ "home_empty_title" to R.string.home_empty_title,
+ "home_empty_hint" to R.string.home_empty_hint,
+ "recent_title" to R.string.recent_title,
+ "recent_all" to R.string.recent_all,
+ "status_looking" to R.string.status_looking,
+ "discovery_title" to R.string.discovery_title,
+ "discovery_body" to R.string.discovery_body,
+ "discovery_pair_again" to R.string.discovery_pair_again,
+ "discovery_enter_address" to R.string.discovery_enter_address,
+ "address_title" to R.string.address_title,
+ "address_hint" to R.string.address_hint,
+ "address_save" to R.string.address_save,
+ "address_bad" to R.string.address_bad,
+ "chat_off_not_paired_title" to R.string.chat_off_not_paired_title,
+ "chat_off_not_paired_body" to R.string.chat_off_not_paired_body,
+ "chat_off_offline_title" to R.string.chat_off_offline_title,
+ "chat_off_offline_body" to R.string.chat_off_offline_body,
+ "chat_off_title" to R.string.chat_off_title,
+ "chat_nomodel_title" to R.string.chat_nomodel_title,
+ "chat_off_hint" to R.string.chat_off_hint,
+ "chat_go_pair" to R.string.chat_go_pair,
+ "chat_go_settings" to R.string.chat_go_settings,
+ "tab_home" to R.string.tab_home,
+ "tab_chat" to R.string.tab_chat,
+ "tab_settings" to R.string.tab_settings,
+ "tab_home_alert" to R.string.tab_home_alert,
+ "design_note" to R.string.design_note,
+ "pair_clipboard" to R.string.pair_clipboard,
+ "notif_unlock" to R.string.notif_unlock,
+ "msg_not_pending" to R.string.msg_not_pending,
+ "msg_bad_link" to R.string.msg_bad_link,
+ "msg_rejected" to R.string.msg_rejected,
+ "msg_link_error" to R.string.msg_link_error,
+ "msg_need_lock" to R.string.msg_need_lock,
+ "approval_hint" to R.string.approval_hint,
+ "overlay_title" to R.string.overlay_title,
+ "overlay_hint" to R.string.overlay_hint,
+ "msg_overlay_permission" to R.string.msg_overlay_permission,
+ "settings_title" to R.string.settings_title,
+ "settings_sound" to R.string.settings_sound,
+ "settings_volume" to R.string.settings_volume,
+ "notify_done" to R.string.notify_done,
+ "notify_done_hint" to R.string.notify_done_hint,
+ "quiet_hours" to R.string.quiet_hours,
+ "quiet_hint" to R.string.quiet_hint,
+ "quiet_from" to R.string.quiet_from,
+ "quiet_to" to R.string.quiet_to,
+ "history_title" to R.string.history_title,
+ "history_empty" to R.string.history_empty,
+ "history_today" to R.string.history_today,
+ "history_yesterday" to R.string.history_yesterday,
+ "history_clear" to R.string.history_clear,
+ "history_note" to R.string.history_note,
+ "action_back" to R.string.action_back,
+ "notif_finished" to R.string.notif_finished,
+ "notif_error" to R.string.notif_error,
+ "notif_question" to R.string.notif_question,
+ "notif_ratelimit" to R.string.notif_ratelimit,
+ "island_answer_on_pc" to R.string.island_answer_on_pc,
+ "state_ready" to R.string.state_ready,
+ "state_working" to R.string.state_working,
+ "state_thinking" to R.string.state_thinking,
+ "state_searching" to R.string.state_searching,
+ "state_approval" to R.string.state_approval,
+ "state_question" to R.string.state_question,
+ "state_error" to R.string.state_error,
+ "state_finished" to R.string.state_finished,
+ "state_ratelimit" to R.string.state_ratelimit,
+ "state_sleeping" to R.string.state_sleeping,
+ "state_dizzy" to R.string.state_dizzy,
+ "agent_kind" to R.string.agent_kind,
+ "link_pair" to R.string.link_pair,
+ "link_approval" to R.string.link_approval,
+ "overlay_missing" to R.string.overlay_missing,
+ "overlay_allow" to R.string.overlay_allow,
+ "settings_section_computer" to R.string.settings_section_computer,
+ "settings_section_away" to R.string.settings_section_away,
+ "relay_use" to R.string.relay_use,
+ "relay_use_hint" to R.string.relay_use_hint,
+ "relay_line_none" to R.string.relay_line_none,
+ "relay_line_off" to R.string.relay_line_off,
+ "relay_line_direct" to R.string.relay_line_direct,
+ "relay_line_via" to R.string.relay_line_via,
+ "relay_line_waiting" to R.string.relay_line_waiting,
+ "relay_line_access" to R.string.relay_line_access,
+ "relay_line_taken" to R.string.relay_line_taken,
+ "relay_line_rate" to R.string.relay_line_rate,
+ "relay_line_unreachable" to R.string.relay_line_unreachable,
+ "relay_line_away" to R.string.relay_line_away,
+ "settings_section_sound" to R.string.settings_section_sound,
+ "settings_language" to R.string.settings_language,
+ "language_system" to R.string.language_system,
+ "language_picker_hint" to R.string.language_picker_hint,
+ "settings_theme" to R.string.settings_theme,
+ "theme_system" to R.string.theme_system,
+ "theme_light" to R.string.theme_light,
+ "theme_dark" to R.string.theme_dark,
+ "settings_dynamic" to R.string.settings_dynamic,
+ "settings_dynamic_hint" to R.string.settings_dynamic_hint,
+ "settings_motion" to R.string.settings_motion,
+ "motion_system" to R.string.motion_system,
+ "motion_on" to R.string.motion_on,
+ "motion_off" to R.string.motion_off,
+ "settings_motion_hint" to R.string.settings_motion_hint,
+ "settings_section_notices" to R.string.settings_section_notices,
+ "settings_section_requests" to R.string.settings_section_requests,
+ "settings_no_wake" to R.string.settings_no_wake,
+ "settings_no_wake_hint" to R.string.settings_no_wake_hint,
+ "settings_vibration" to R.string.settings_vibration,
+ "vibration_standard" to R.string.vibration_standard,
+ "vibration_short" to R.string.vibration_short,
+ "vibration_off" to R.string.vibration_off,
+ "settings_requests_note" to R.string.settings_requests_note,
+ "settings_section_display" to R.string.settings_section_display,
+ "settings_section_more" to R.string.settings_section_more,
+ "settings_section_about" to R.string.settings_section_about,
+ "settings_computer_none" to R.string.settings_computer_none,
+ "action_cancel" to R.string.action_cancel,
+ "chat_title" to R.string.chat_title,
+ "chat_note" to R.string.chat_note,
+ "chat_empty" to R.string.chat_empty,
+ "chat_placeholder" to R.string.chat_placeholder,
+ "chat_send" to R.string.chat_send,
+ "chat_stop" to R.string.chat_stop,
+ "chat_clear" to R.string.chat_clear,
+ "chat_clear_title" to R.string.chat_clear_title,
+ "chat_clear_body" to R.string.chat_clear_body,
+ "chat_model" to R.string.chat_model,
+ "chat_count" to R.string.chat_count,
+ "chat_ref_too_long" to R.string.chat_ref_too_long,
+ "chat_ref_no_model" to R.string.chat_ref_no_model,
+ "chat_ref_busy" to R.string.chat_ref_busy,
+ "chat_ref_offline" to R.string.chat_ref_offline,
+ "chat_err_off" to R.string.chat_err_off,
+ "chat_err_not_allowed" to R.string.chat_err_not_allowed,
+ "chat_err_busy" to R.string.chat_err_busy,
+ "chat_err_rate" to R.string.chat_err_rate,
+ "chat_err_too_long" to R.string.chat_err_too_long,
+ "chat_err_empty" to R.string.chat_err_empty,
+ "chat_err_no_key" to R.string.chat_err_no_key,
+ "chat_err_unreachable" to R.string.chat_err_unreachable,
+ "chat_err_auth" to R.string.chat_err_auth,
+ "chat_err_provider" to R.string.chat_err_provider,
+ "chat_err_canceled" to R.string.chat_err_canceled,
+ "chat_err_internal" to R.string.chat_err_internal,
+ "chat_err_connection" to R.string.chat_err_connection,
+ "chat_err_interrupted" to R.string.chat_err_interrupted,
+ "session_details" to R.string.session_details,
+ "session_last" to R.string.session_last,
+ "session_steps" to R.string.session_steps,
+ "session_step_working" to R.string.session_step_working,
+ "session_step_done" to R.string.session_step_done,
+ "session_no_steps" to R.string.session_no_steps,
+ "session_hint" to R.string.session_hint,
+ "session_ended" to R.string.session_ended,
+ "session_project" to R.string.session_project,
+ "scan_button" to R.string.scan_button,
+ "scan_title" to R.string.scan_title,
+ "scan_hint" to R.string.scan_hint,
+ "scan_not_pairing" to R.string.scan_not_pairing,
+ "scan_why" to R.string.scan_why,
+ "scan_allow" to R.string.scan_allow,
+ "scan_blocked" to R.string.scan_blocked,
+ "scan_open_settings" to R.string.scan_open_settings,
+ "scan_paste_instead" to R.string.scan_paste_instead,
+ "scan_camera_error" to R.string.scan_camera_error,
+ "pair_confirm_title" to R.string.pair_confirm_title,
+ "pair_confirm_body" to R.string.pair_confirm_body,
+ "pair_confirm_relay" to R.string.pair_confirm_relay,
+ "pair_confirm_replace" to R.string.pair_confirm_replace,
+ "pair_confirm_ok" to R.string.pair_confirm_ok,
+ "wardrobe_title" to R.string.wardrobe_title,
+ "wardrobe_note" to R.string.wardrobe_note,
+ "wardrobe_follow" to R.string.wardrobe_follow,
+ "wardrobe_follow_hint" to R.string.wardrobe_follow_hint,
+ "wardrobe_auto_tag" to R.string.wardrobe_auto_tag,
+ "wardrobe_selected" to R.string.wardrobe_selected,
+ "outfit_auto" to R.string.outfit_auto,
+ "outfit_none" to R.string.outfit_none,
+ "outfit_partyHat" to R.string.outfit_partyHat,
+ "outfit_beanie" to R.string.outfit_beanie,
+ "outfit_crown" to R.string.outfit_crown,
+ "outfit_sunglasses" to R.string.outfit_sunglasses,
+ "outfit_roundGlasses" to R.string.outfit_roundGlasses,
+ "outfit_bow" to R.string.outfit_bow,
+ "outfit_scarf" to R.string.outfit_scarf,
+ "outfit_witchHat" to R.string.outfit_witchHat,
+ "outfit_pumpkin" to R.string.outfit_pumpkin,
+ "outfit_santaHat" to R.string.outfit_santaHat,
+ "outfit_bunnyEars" to R.string.outfit_bunnyEars,
+ "files_heading" to R.string.files_heading,
+ "files_counts" to R.string.files_counts,
+ "files_new" to R.string.files_new,
+ "file_loading" to R.string.file_loading,
+ "file_failed" to R.string.file_failed,
+ "file_gone" to R.string.file_gone,
+ "file_too_large" to R.string.file_too_large,
+ "file_truncated" to R.string.file_truncated,
+ "file_empty" to R.string.file_empty,
+ "file_close" to R.string.file_close,
+ "file_summary" to R.string.file_summary,
+ "usage_title" to R.string.usage_title,
+ "usage_claude" to R.string.usage_claude,
+ "usage_codex" to R.string.usage_codex,
+ "usage_five_hours" to R.string.usage_five_hours,
+ "usage_week" to R.string.usage_week,
+ "usage_pct" to R.string.usage_pct,
+ "usage_resets_now" to R.string.usage_resets_now,
+ "usage_resets_hm" to R.string.usage_resets_hm,
+ "usage_resets_m" to R.string.usage_resets_m,
+ "usage_resets_week" to R.string.usage_resets_week,
+ "usage_credits" to R.string.usage_credits,
+ "usage_desc" to R.string.usage_desc,
+ "services_title" to R.string.services_title,
+ "diag_title" to R.string.diag_title,
+ "diag_intro" to R.string.diag_intro,
+ "diag_run" to R.string.diag_run,
+ "diag_running" to R.string.diag_running,
+ "diag_copy" to R.string.diag_copy,
+ "diag_copied" to R.string.diag_copied,
+ "diag_ok" to R.string.diag_ok,
+ "diag_problem" to R.string.diag_problem,
+ "diag_skipped" to R.string.diag_skipped,
+ "battery_title" to R.string.battery_title,
+ "battery_body" to R.string.battery_body,
+ "battery_open" to R.string.battery_open,
+ "battery_not_now" to R.string.battery_not_now,
+ "ago_less_than_minute" to R.string.ago_less_than_minute,
+ "ago_minutes" to R.string.ago_minutes,
+ "ago_hours" to R.string.ago_hours,
+ "ago_hours_minutes" to R.string.ago_hours_minutes,
+ "lost_silent" to R.string.lost_silent,
+ "lost_closed" to R.string.lost_closed,
+ "lost_no_wifi" to R.string.lost_no_wifi,
+ "lost_unreachable" to R.string.lost_unreachable,
+ "lost_head" to R.string.lost_head,
+ "lost_tries" to R.string.lost_tries,
+ "battery_step_samsung_1" to R.string.battery_step_samsung_1,
+ "battery_step_samsung_2" to R.string.battery_step_samsung_2,
+ "battery_step_generic" to R.string.battery_step_generic,
+ "tool_action_other" to R.string.tool_action_other,
+ "tool_a_file" to R.string.tool_a_file,
+ "tool_asking" to R.string.tool_asking,
+ "tool_running" to R.string.tool_running,
+ "tool_reading" to R.string.tool_reading,
+ "tool_editing" to R.string.tool_editing,
+ "tool_searching" to R.string.tool_searching,
+ "tool_looking" to R.string.tool_looking,
+ "tool_web_search" to R.string.tool_web_search,
+ "tool_web_page" to R.string.tool_web_page,
+ "tool_subagent" to R.string.tool_subagent,
+ "tool_planning" to R.string.tool_planning,
+ "tool_action_ask" to R.string.tool_action_ask,
+ "tool_action_run" to R.string.tool_action_run,
+ "tool_action_read" to R.string.tool_action_read,
+ "tool_action_edit" to R.string.tool_action_edit,
+ "tool_action_search" to R.string.tool_action_search,
+ "tool_action_look" to R.string.tool_action_look,
+ "tool_action_web_search" to R.string.tool_action_web_search,
+ "tool_action_web_page" to R.string.tool_action_web_page,
+ "tool_action_subagent" to R.string.tool_action_subagent,
+ "usage_resets_at" to R.string.usage_resets_at,
+ "usage_resets_day" to R.string.usage_resets_day,
+ "usage_resets_date" to R.string.usage_resets_date,
+ "usage_near_limit" to R.string.usage_near_limit,
+ "widget_waiting_computer" to R.string.widget_waiting_computer,
+ "widget_no_agents" to R.string.widget_no_agents,
+ "widget_all_calm" to R.string.widget_all_calm,
+ "widget_waiting_pc" to R.string.widget_waiting_pc,
+ "widget_nothing_needs_you" to R.string.widget_nothing_needs_you,
+ "usage_window_5h" to R.string.usage_window_5h,
+ "usage_window_week" to R.string.usage_window_week,
+ "glance_not_paired" to R.string.glance_not_paired,
+ "glance_not_paired_detail" to R.string.glance_not_paired_detail,
+ "glance_reaching" to R.string.glance_reaching,
+ "glance_cannot_reach" to R.string.glance_cannot_reach,
+ "glance_waiting_you" to R.string.glance_waiting_you,
+ "glance_waiting_answer" to R.string.glance_waiting_answer,
+ "glance_needs_look" to R.string.glance_needs_look,
+ "glance_one_working" to R.string.glance_one_working,
+ "glance_on" to R.string.glance_on,
+ "glance_all_done" to R.string.glance_all_done,
+ "glance_to" to R.string.glance_to,
+ "glance_nothing_running" to R.string.glance_nothing_running,
+ "glance_line_approval" to R.string.glance_line_approval,
+ "glance_line_limit" to R.string.glance_line_limit,
+ "glance_line_dizzy" to R.string.glance_line_dizzy,
+ "glance_line_idle" to R.string.glance_line_idle,
+ "mood_calm" to R.string.mood_calm,
+ "mood_working" to R.string.mood_working,
+ "mood_thinking" to R.string.mood_thinking,
+ "mood_searching" to R.string.mood_searching,
+ "mood_waiting" to R.string.mood_waiting,
+ "mood_question" to R.string.mood_question,
+ "mood_error" to R.string.mood_error,
+ "mood_happy" to R.string.mood_happy,
+ "mood_limit" to R.string.mood_limit,
+ "mood_asleep" to R.string.mood_asleep,
+ "mood_dizzy" to R.string.mood_dizzy,
+ "home_recent_allowed" to R.string.home_recent_allowed,
+ "home_recent_denied" to R.string.home_recent_denied,
+ "agent_an" to R.string.agent_an,
+ "home_decision_allowed" to R.string.home_decision_allowed,
+ "home_decision_denied" to R.string.home_decision_denied,
+ )
+
+ val plurals: Map<String, Int> = mapOf(
+ "widget_n_waiting" to R.plurals.widget_n_waiting,
+ "glance_requests" to R.plurals.glance_requests,
+ "glance_questions" to R.plurals.glance_questions,
+ "glance_stopped" to R.plurals.glance_stopped,
+ "glance_working_many" to R.plurals.glance_working_many,
+ "spoken_waiting_you" to R.plurals.spoken_waiting_you,
+ )
+}
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/Glance.kt b/android/app/src/main/kotlin/com/coucou/android/core/Glance.kt
index 70389082..af8ebd38 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/Glance.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/Glance.kt
@@ -54,12 +54,12 @@ object GlanceBuilder {
approvals: Int,
nameOf: (String) -> String,
): Glance {
- if (!paired) return Glance("Not paired", "Open Coucou to connect to your computer", GlanceTone.CALM, false, emptyList(), 0)
+ if (!paired) return Glance(Texts.t("glance_not_paired", "Not paired"), Texts.t("glance_not_paired_detail", "Open Coucou to connect to your computer"), GlanceTone.CALM, false, emptyList(), 0)
if (link != LinkState.CONNECTED) {
val connecting = link == LinkState.CONNECTING
return Glance(
- if (connecting) "Connecting…" else "Not connected",
- if (connecting) "Reaching your computer" else "Coucou cannot reach your computer",
+ if (connecting) Texts.t("status_connecting", "Connecting…") else Texts.t("status_not_connected", "Not connected"),
+ if (connecting) Texts.t("glance_reaching", "Reaching your computer") else Texts.t("glance_cannot_reach", "Coucou cannot reach your computer"),
GlanceTone.CALM, false, emptyList(), 0,
)
}
@@ -72,43 +72,44 @@ object GlanceBuilder {
val where = desktop?.takeIf { it.isNotBlank() }
return when {
approvals > 0 -> Glance(
- "Waiting for you",
- if (approvals == 1) "1 request to approve" else "$approvals requests to approve",
+ Texts.t("glance_waiting_you", "Waiting for you"),
+ Texts.n("glance_requests", approvals, "%1\$d request to approve", "%1\$d requests to approve"),
GlanceTone.ATTENTION, true, lines, waiting,
)
questions > 0 -> Glance(
- "Waiting for your answer",
- if (questions == 1) "1 question from an agent" else "$questions questions from agents",
+ Texts.t("glance_waiting_answer", "Waiting for your answer"),
+ Texts.n("glance_questions", questions, "%1\$d question from an agent", "%1\$d questions from agents"),
GlanceTone.ATTENTION, true, lines, waiting,
)
trouble > 0 -> Glance(
- "An agent needs a look",
- if (trouble == 1) "1 agent stopped" else "$trouble agents stopped",
+ Texts.t("glance_needs_look", "An agent needs a look"),
+ Texts.n("glance_stopped", trouble, "%1\$d agent stopped", "%1\$d agents stopped"),
GlanceTone.TROUBLE, true, lines, 0,
)
busy > 0 -> Glance(
- if (busy == 1) "${nameOf(ranked.first { it.state in BUSY }.pillId)} is working" else "$busy agents are working",
- where?.let { "On $it" } ?: "Working",
+ if (busy == 1) Texts.t("glance_one_working", "%1\$s is working", nameOf(ranked.first { it.state in BUSY }.pillId))
+ else Texts.n("glance_working_many", busy, "%1\$d agent is working", "%1\$d agents are working"),
+ where?.let { Texts.t("glance_on", "On %1\$s", it) } ?: Texts.t("state_working", "Working"),
GlanceTone.BUSY, true, lines, 0,
)
sessions.any { it.state == BotState.FINISHED } -> Glance(
- "All done", where?.let { "On $it" } ?: "Finished", GlanceTone.OK, true, lines, 0,
+ Texts.t("glance_all_done", "All done"), where?.let { Texts.t("glance_on", "On %1\$s", it) } ?: Texts.t("state_finished", "Finished"), GlanceTone.OK, true, lines, 0,
)
- else -> Glance("Connected", where?.let { "To $it" } ?: "Nothing is running", GlanceTone.OK, true, lines, 0)
+ else -> Glance(Texts.t("status_connected", "Connected"), where?.let { Texts.t("glance_to", "To %1\$s", it) } ?: Texts.t("glance_nothing_running", "Nothing is running"), GlanceTone.OK, true, lines, 0)
}
}
/** The plain line of a session: its state in a few words, never its step text or answer (those stay in the app). */
fun lineOf(s: SessionInfo): String = when (s.state) {
- BotState.APPROVAL -> "Waiting for your approval"
- BotState.QUESTION -> "Has a question"
- BotState.ERROR -> "Stopped on an error"
- BotState.RATELIMIT -> "Hit a limit"
- BotState.DIZZY -> "Needs a look"
- BotState.FINISHED -> "Finished"
- BotState.SLEEPING, BotState.IDLE -> "Idle"
- BotState.THINKING -> "Thinking"
- BotState.SEARCHING -> "Searching"
- else -> "Working" // never the step text: it can hold a file name or a command
+ BotState.APPROVAL -> Texts.t("glance_line_approval", "Waiting for your approval")
+ BotState.QUESTION -> Texts.t("notif_question", "Has a question")
+ BotState.ERROR -> Texts.t("notif_error", "Stopped on an error")
+ BotState.RATELIMIT -> Texts.t("glance_line_limit", "Hit a limit")
+ BotState.DIZZY -> Texts.t("glance_line_dizzy", "Needs a look")
+ BotState.FINISHED -> Texts.t("state_finished", "Finished")
+ BotState.SLEEPING, BotState.IDLE -> Texts.t("glance_line_idle", "Idle")
+ BotState.THINKING -> Texts.t("state_thinking", "Thinking")
+ BotState.SEARCHING -> Texts.t("state_searching", "Searching")
+ else -> Texts.t("state_working", "Working") // never the step text: it can hold a file name or a command
}
}
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/HomeText.kt b/android/app/src/main/kotlin/com/coucou/android/core/HomeText.kt
index 7ddf3734..f51123af 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/HomeText.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/HomeText.kt
@@ -17,11 +17,15 @@ object HomeText {
}
/** "Allowed: edit files" or "Denied: run a command", for the Recent list. */
- fun recent(allowed: Boolean, tool: String): String = (if (allowed) "Allowed: " else "Denied: ") + ToolLabels.action(tool)
+ fun recent(allowed: Boolean, tool: String): String =
+ if (allowed) Texts.t("home_recent_allowed", "Allowed: %1\$s", ToolLabels.action(tool)) else Texts.t("home_recent_denied", "Denied: %1\$s", ToolLabels.action(tool))
/** "You allowed Claude Code to run a command": a decision in a sentence, with no command and no path. */
- fun decision(allowed: Boolean, agent: String, tool: String): String =
- "You ${if (allowed) "allowed" else "denied"} ${agent.ifBlank { "an agent" }} to ${ToolLabels.action(tool)}"
+ fun decision(allowed: Boolean, agent: String, tool: String): String {
+ val who = agent.ifBlank { Texts.t("agent_an", "an agent") }
+ return if (allowed) Texts.t("home_decision_allowed", "You allowed %1\$s to %2\$s", who, ToolLabels.action(tool))
+ else Texts.t("home_decision_denied", "You denied %1\$s to %2\$s", who, ToolLabels.action(tool))
+ }
/** How many agents are busy (working, thinking or searching), for "2 running". */
fun running(sessions: List<SessionInfo>): Int = sessions.count { it.state in BUSY }
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/SafeText.kt b/android/app/src/main/kotlin/com/coucou/android/core/SafeText.kt
index c4df90c2..2459a5d8 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/SafeText.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/SafeText.kt
@@ -34,7 +34,7 @@ object SafeText {
/** "Running a command · npm" for a shell tool, "Editing files" for the others: the label of a request. */
fun requestLabel(tool: String, command: String?): String {
- val label = ToolLabels.label(tool).ifEmpty { "Working" }
+ val label = ToolLabels.label(tool).ifEmpty { Texts.t("state_working", "Working") }
val program = if (isShell(tool)) program(command) else null
return if (program != null) "$label · $program" else label
}
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/Texts.kt b/android/app/src/main/kotlin/com/coucou/android/core/Texts.kt
new file mode 100644
index 00000000..5ca166e2
--- /dev/null
+++ b/android/app/src/main/kotlin/com/coucou/android/core/Texts.kt
@@ -0,0 +1,35 @@
+package com.coucou.android.core
+
+import java.util.Locale
+
+/**
+ * The words that the pure rules produce ("Running a command", "2 agents are working", "resets at 14:30") go through here, so they follow the
+ * app's language like every other string. The app installs a [Source] that looks the key up in the string resources; with none (the unit
+ * tests, which are English) the English written next to the key is used. A test checks that each English text in the code is the one in
+ * i18n/app-strings.json, so the two can never differ.
+ */
+object Texts {
+ /** Where translated texts come from: the string resources of the app, in the language chosen. */
+ interface Source {
+ fun string(key: String): String?
+ /** The text for [count] in the language's plural rule; null when there is none. */
+ fun plural(key: String, count: Int): String?
+ }
+
+ @Volatile var source: Source? = null
+
+ /** The text of [key], formatted with [args] (positional, "%1$s"); [english] when there is no translation. */
+ fun t(key: String, english: String, vararg args: Any?): String = format(source?.string(key) ?: english, args)
+
+ /**
+ * A text that depends on a number: [one] and [other] are the English forms ("%1$d request", "%1$d requests"); the count is the first
+ * argument, [extra] come after it. In other languages the plural rule of the language picks the form.
+ */
+ fun n(key: String, count: Int, one: String, other: String, vararg extra: Any?): String {
+ val template = source?.plural(key, count) ?: if (count == 1) one else other
+ return format(template, arrayOf<Any?>(count, *extra))
+ }
+
+ private fun format(template: String, args: Array<out Any?>): String =
+ if (args.isEmpty()) template else String.format(Locale.getDefault(), template, *args)
+}
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/ToolLabels.kt b/android/app/src/main/kotlin/com/coucou/android/core/ToolLabels.kt
index 7b24d795..d9d5d3c7 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/ToolLabels.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/ToolLabels.kt
@@ -7,50 +7,95 @@ package com.coucou.android.core
* as "Running npm test" is left alone. Used by the Home card and the island, so both say the same.
*/
object ToolLabels {
+ /** Tool name (lower case, no separators) to the key of its sentence; the English is in [KNOWN_ENGLISH]. */
private val KNOWN = mapOf(
- "askuserquestion" to "Asking a question",
- "askquestion" to "Asking a question",
- "bash" to "Running a command",
- "shell" to "Running a command",
- "runshellcommand" to "Running a command",
- "execcommand" to "Running a command",
- "read" to "Reading files",
- "readfile" to "Reading files",
- "readmanyfiles" to "Reading files",
- "edit" to "Editing files",
- "multiedit" to "Editing files",
- "write" to "Editing files",
- "writefile" to "Editing files",
- "notebookedit" to "Editing files",
- "applypatch" to "Editing files",
- "grep" to "Searching files",
- "glob" to "Searching files",
- "ls" to "Looking at files",
- "websearch" to "Searching the web",
- "googlewebsearch" to "Searching the web",
- "webfetch" to "Reading a web page",
- "task" to "Running a sub-agent",
- "todowrite" to "Planning",
- "exitplanmode" to "Planning",
+ "askuserquestion" to "tool_asking",
+ "askquestion" to "tool_asking",
+ "bash" to "tool_running",
+ "shell" to "tool_running",
+ "runshellcommand" to "tool_running",
+ "execcommand" to "tool_running",
+ "read" to "tool_reading",
+ "readfile" to "tool_reading",
+ "readmanyfiles" to "tool_reading",
+ "edit" to "tool_editing",
+ "multiedit" to "tool_editing",
+ "write" to "tool_editing",
+ "writefile" to "tool_editing",
+ "notebookedit" to "tool_editing",
+ "applypatch" to "tool_editing",
+ "grep" to "tool_searching",
+ "glob" to "tool_searching",
+ "ls" to "tool_looking",
+ "websearch" to "tool_web_search",
+ "googlewebsearch" to "tool_web_search",
+ "webfetch" to "tool_web_page",
+ "task" to "tool_subagent",
+ "todowrite" to "tool_planning",
+ "exitplanmode" to "tool_planning",
)
+ /** The sentences, one per key; the same texts are in i18n/app-strings.json (a test keeps them in step). */
+ private val KNOWN_ENGLISH = mapOf(
+ "tool_asking" to "Asking a question",
+ "tool_running" to "Running a command",
+ "tool_reading" to "Reading files",
+ "tool_editing" to "Editing files",
+ "tool_searching" to "Searching files",
+ "tool_looking" to "Looking at files",
+ "tool_web_search" to "Searching the web",
+ "tool_web_page" to "Reading a web page",
+ "tool_subagent" to "Running a sub-agent",
+ "tool_planning" to "Planning",
+ )
+
+ private fun known(name: String): String? = KNOWN[key(name)]?.let { Texts.t(it, KNOWN_ENGLISH.getValue(it)) }
+
/** The same tools as an action after "wants to" or "Allowed:": "run a command", "edit files". */
private val ACTIONS = mapOf(
- "askuserquestion" to "ask a question", "askquestion" to "ask a question",
- "bash" to "run a command", "shell" to "run a command", "runshellcommand" to "run a command", "execcommand" to "run a command",
- "read" to "read files", "readfile" to "read files", "readmanyfiles" to "read files",
- "edit" to "edit files", "multiedit" to "edit files", "write" to "edit files", "writefile" to "edit files",
- "notebookedit" to "edit files", "applypatch" to "edit files",
- "grep" to "search files", "glob" to "search files", "ls" to "look at files",
- "websearch" to "search the web", "googlewebsearch" to "search the web", "webfetch" to "read a web page",
- "task" to "run a sub-agent",
+ "askuserquestion" to "tool_action_ask",
+ "askquestion" to "tool_action_ask",
+ "bash" to "tool_action_run",
+ "shell" to "tool_action_run",
+ "runshellcommand" to "tool_action_run",
+ "execcommand" to "tool_action_run",
+ "read" to "tool_action_read",
+ "readfile" to "tool_action_read",
+ "readmanyfiles" to "tool_action_read",
+ "edit" to "tool_action_edit",
+ "multiedit" to "tool_action_edit",
+ "write" to "tool_action_edit",
+ "writefile" to "tool_action_edit",
+ "notebookedit" to "tool_action_edit",
+ "applypatch" to "tool_action_edit",
+ "grep" to "tool_action_search",
+ "glob" to "tool_action_search",
+ "ls" to "tool_action_look",
+ "websearch" to "tool_action_web_search",
+ "googlewebsearch" to "tool_action_web_search",
+ "webfetch" to "tool_action_web_page",
+ "task" to "tool_action_subagent",
)
+ private val ACTIONS_ENGLISH = mapOf(
+ "tool_action_ask" to "ask a question",
+ "tool_action_run" to "run a command",
+ "tool_action_read" to "read files",
+ "tool_action_edit" to "edit files",
+ "tool_action_search" to "search files",
+ "tool_action_look" to "look at files",
+ "tool_action_web_search" to "search the web",
+ "tool_action_web_page" to "read a web page",
+ "tool_action_subagent" to "run a sub-agent",
+ )
+
+ private fun actionOf(name: String): String? = ACTIONS[key(name)]?.let { Texts.t(it, ACTIONS_ENGLISH.getValue(it)) }
+
/** What a request is for, as an action ("run a command"); an unknown tool is cleaned and lower-cased. */
fun action(tool: String): String {
val name = tool.trim()
- if (name.isEmpty()) return "do something"
- return ACTIONS[key(name)] ?: clean(name).lowercase()
+ if (name.isEmpty()) return Texts.t("tool_action_other", "do something")
+ return actionOf(name) ?: clean(name).lowercase()
}
private const val SEP = " · "
@@ -75,10 +120,10 @@ object ToolLabels {
val rest = if (at > 0) text.substring(at + SEP.length).trim() else ""
if (!looksLikeAName(head)) return ""
// A file name where a tool's name should be ("SessionScreen.kt"): never cleaned into words, only "A file".
- if (looksLikeAFile(head)) return "A file"
+ if (looksLikeAFile(head)) return Texts.t("tool_a_file", "A file")
// An unknown word shows only if it can be a tool's name: a key or a token pasted in its place never does.
- if (KNOWN[key(head)] == null && !plausibleToolName(head)) return ""
- val tool = KNOWN[key(head)] ?: clean(head)
+ if (known(head) == null && !plausibleToolName(head)) return ""
+ val tool = known(head) ?: clean(head)
val program = if (rest.isNotEmpty()) SafeText.requestLabel(head, rest).substringAfter(SEP, "") else ""
return if (program.isNotEmpty()) "$tool$SEP$program" else tool
}
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/WidgetData.kt b/android/app/src/main/kotlin/com/coucou/android/core/WidgetData.kt
index 14124afb..a16a6065 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/WidgetData.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/WidgetData.kt
@@ -111,16 +111,17 @@ object PlanUsageLook {
val at = Instant.ofEpochMilli(resetsAtMs).atZone(zone)
val days = ChronoUnit.DAYS.between(Instant.ofEpochMilli(nowMs).atZone(zone).toLocalDate(), at.toLocalDate())
val clock = "%02d:%02d".format(at.hour, at.minute)
+ val locale = Locale.getDefault()
return when {
- days == 0L -> "resets at $clock"
- days < 7 -> "resets ${at.dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.ENGLISH)} $clock"
- else -> "resets ${at.month.getDisplayName(TextStyle.SHORT, Locale.ENGLISH)} ${at.dayOfMonth} $clock"
+ days == 0L -> Texts.t("usage_resets_at", "resets at %1\$s", clock)
+ days < 7 -> Texts.t("usage_resets_day", "resets %1\$s %2\$s", at.dayOfWeek.getDisplayName(TextStyle.SHORT, locale), clock)
+ else -> Texts.t("usage_resets_date", "resets %1\$s %2\$d %3\$s", at.month.getDisplayName(TextStyle.SHORT, locale), at.dayOfMonth, clock)
}
}
/** "Near limit" (with the reset time when known) from the red line; null below it, where there is no warning. */
fun note(pct: Int, resetsAtMs: Long, nowMs: Long, zone: ZoneId = ZoneId.systemDefault()): String? =
- if (!nearLimit(pct)) null else listOfNotNull("Near limit", resetLine(resetsAtMs, nowMs, zone)).joinToString(" · ")
+ if (!nearLimit(pct)) null else listOfNotNull(Texts.t("usage_near_limit", "Near limit"), resetLine(resetsAtMs, nowMs, zone)).joinToString(" · ")
}
/** The plan usage a ring or a bar shows: which plan and window, how much of it is used, and the warning line when it is near the limit. */
@@ -177,22 +178,22 @@ data class WidgetContent(
/** The one clear line when there is no agent to list: the computer is not there, or nothing runs. Null when there are agents. */
val emptyLine: String? get() = when {
tiles.isNotEmpty() -> null
- !connected -> "Waiting for your computer"
- else -> "No agents running"
+ !connected -> Texts.t("widget_waiting_computer", "Waiting for your computer")
+ else -> Texts.t("widget_no_agents", "No agents running")
}
/** The Waiting Alert's line: "2 waiting" in orange, or a calm word. */
val alertLine: String get() = when {
- !connected -> "Not connected"
- waiting > 0 -> "$waiting waiting"
- else -> "All calm"
+ !connected -> Texts.t("status_not_connected", "Not connected")
+ waiting > 0 -> Texts.n("widget_n_waiting", waiting, "%1\$d waiting", "%1\$d waiting")
+ else -> Texts.t("widget_all_calm", "All calm")
}
/** The line under the alert: who is waiting, or why there is nothing to say. */
val alertSub: String get() = when {
- !connected -> "Waiting for your PC"
+ !connected -> Texts.t("widget_waiting_pc", "Waiting for your PC")
waiting > 0 -> top?.name.orEmpty()
- else -> "Nothing needs you"
+ else -> Texts.t("widget_nothing_needs_you", "Nothing needs you")
}
/** Mochi's face on the Today widget: pleased once something finished today, calm before. */
@@ -273,7 +274,7 @@ object WidgetData {
fun usageRows(usage: UsageSnapshot?, nowMs: Long): List<UsageRing> {
usage ?: return emptyList()
return listOf("Claude" to usage.claude, "Codex" to usage.codex).mapNotNull { (name, plan) ->
- plan?.fiveHour?.let { row(name, "5 h", it, nowMs) } ?: plan?.sevenDay?.let { row(name, "week", it, nowMs) }
+ plan?.fiveHour?.let { row(name, WINDOW_5H, it, nowMs) } ?: plan?.sevenDay?.let { row(name, WINDOW_WEEK, it, nowMs) }
}
}
@@ -326,6 +327,10 @@ object WidgetData {
private const val HOUR_MS = 3_600_000L
+ /** The window names of a plan row, in the app's language ("5 h", "week"). */
+ private val WINDOW_5H: String get() = Texts.t("usage_window_5h", "5 h")
+ private val WINDOW_WEEK: String get() = Texts.t("usage_window_week", "week")
+
/** One row: the percentage counted as zero once the window has reset, and the "Near limit" line with its reset time. */
private fun row(plan: String, window: String, w: PlanWindow, nowMs: Long): UsageRing {
val pct = PlanText.effectivePct(w, nowMs)
@@ -338,7 +343,7 @@ object WidgetData {
for ((name, plan) in listOf("Claude" to usage.claude, "Codex" to usage.codex)) {
plan ?: continue
plan.fiveHour?.let { return row(name, "5 h", it, nowMs) }
- plan.sevenDay?.let { return row(name, "week", it, nowMs) }
+ plan.sevenDay?.let { return row(name, WINDOW_WEEK, it, nowMs) }
}
return null
}
diff --git a/android/app/src/main/kotlin/com/coucou/android/core/WidgetSpoken.kt b/android/app/src/main/kotlin/com/coucou/android/core/WidgetSpoken.kt
index 481768e7..fdde4be1 100644
--- a/android/app/src/main/kotlin/com/coucou/android/core/WidgetSpoken.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/core/WidgetSpoken.kt
@@ -9,17 +9,17 @@ import com.coucou.android.mochi.BotState
object WidgetSpoken {
/** Mochi's mood in plain words ("waiting for you"), not the engine's key ("approval"). */
fun mood(state: BotState): String = when (state) {
- BotState.IDLE -> "calm"
- BotState.WORKING -> "working"
- BotState.THINKING -> "thinking"
- BotState.SEARCHING -> "searching"
- BotState.APPROVAL -> "waiting for you"
- BotState.QUESTION -> "has a question"
- BotState.ERROR -> "in trouble"
- BotState.FINISHED -> "happy"
- BotState.RATELIMIT -> "at a limit"
- BotState.SLEEPING -> "asleep"
- BotState.DIZZY -> "dizzy"
+ BotState.IDLE -> Texts.t("mood_calm", "calm")
+ BotState.WORKING -> Texts.t("mood_working", "working")
+ BotState.THINKING -> Texts.t("mood_thinking", "thinking")
+ BotState.SEARCHING -> Texts.t("mood_searching", "searching")
+ BotState.APPROVAL -> Texts.t("mood_waiting", "waiting for you")
+ BotState.QUESTION -> Texts.t("mood_question", "has a question")
+ BotState.ERROR -> Texts.t("mood_error", "in trouble")
+ BotState.FINISHED -> Texts.t("mood_happy", "happy")
+ BotState.RATELIMIT -> Texts.t("mood_limit", "at a limit")
+ BotState.SLEEPING -> Texts.t("mood_asleep", "asleep")
+ BotState.DIZZY -> Texts.t("mood_dizzy", "dizzy")
}
/** One agent: "Claude Code, waiting for your approval". */
@@ -28,12 +28,13 @@ object WidgetSpoken {
/** The tapped card of Solo and Mood: the top agent, or the headline when there is none; with what waits for you. */
fun top(c: WidgetContent): String {
val base = c.top?.let { tile(it) } ?: SpokenLabels.agent(c.headline, c.emptyLine.orEmpty(), null)
- return if (c.waiting > 0 && c.top != null) "$base. ${c.waiting} waiting for you" else base
+ return if (c.waiting > 0 && c.top != null) "$base. ${Texts.n("spoken_waiting_you", c.waiting, "%1\$d waiting for you", "%1\$d waiting for you")}" else base
}
/** Waiting Alert: "1 waiting. Claude Code", "All calm. Nothing needs you", "Not connected. Waiting for your PC". */
fun alert(c: WidgetContent): String = "${c.alertLine}. ${c.alertSub}"
/** The header of the list. */
- fun list(c: WidgetContent): String = if (c.waiting > 0) "${c.headline}. ${c.waiting} waiting for you" else c.headline
+ fun list(c: WidgetContent): String =
+ if (c.waiting > 0) "${c.headline}. ${Texts.n("spoken_waiting_you", c.waiting, "%1\$d waiting for you", "%1\$d waiting for you")}" else c.headline
}
diff --git a/android/app/src/main/kotlin/com/coucou/android/link/LinkHealth.kt b/android/app/src/main/kotlin/com/coucou/android/link/LinkHealth.kt
index 17850c95..fb117860 100644
--- a/android/app/src/main/kotlin/com/coucou/android/link/LinkHealth.kt
+++ b/android/app/src/main/kotlin/com/coucou/android/link/LinkHealth.kt
@@ -1,5 +1,7 @@
package com.coucou.android.link
+import com.coucou.android.core.Texts
+
/**
* What the phone knows about the health of the link, in plain terms, so Home can say what happened ("Connection lost 2 min ago,
* reconnecting") instead of showing a silent state. Pure: the clock is passed in, so every sentence is a unit test.
@@ -27,10 +29,10 @@ object LinkHealthText {
fun ago(ms: Long): String {
val minutes = (ms.coerceAtLeast(0) / 60_000).toInt()
return when {
- minutes < 1 -> "less than a minute"
- minutes < 60 -> "$minutes min"
- minutes % 60 == 0 -> "${minutes / 60} h"
- else -> "${minutes / 60} h ${minutes % 60} min"
+ minutes < 1 -> Texts.t("ago_less_than_minute", "less than a minute")
+ minutes < 60 -> Texts.t("ago_minutes", "%1\$d min", minutes)
+ minutes % 60 == 0 -> Texts.t("ago_hours", "%1\$d h", minutes / 60)
+ else -> Texts.t("ago_hours_minutes", "%1\$d h %2\$d min", minutes / 60, minutes % 60)
}
}
@@ -39,11 +41,11 @@ object LinkHealthText {
* phone cannot see the computer's side, so a cause it cannot know is a short list of what to look at, never a guess stated as fact.
*/
fun why(reason: LostReason?, wifiUp: Boolean = true) = when (reason) {
- LostReason.SILENT -> "The computer stopped answering. This is usual after the phone slept."
- LostReason.CLOSED -> "The computer closed the connection. Coucou may have been closed or restarted there."
+ LostReason.SILENT -> Texts.t("lost_silent", "The computer stopped answering. This is usual after the phone slept.")
+ LostReason.CLOSED -> Texts.t("lost_closed", "The computer closed the connection. Coucou may have been closed or restarted there.")
LostReason.NETWORK ->
- if (!wifiUp) "The phone is not on Wi-Fi. Join the network your computer is on, or use the internet link."
- else "The phone cannot reach the computer. Coucou may be closed there, its phone link may be off, or it is on another network."
+ if (!wifiUp) Texts.t("lost_no_wifi", "The phone is not on Wi-Fi. Join the network your computer is on, or use the internet link.")
+ else Texts.t("lost_unreachable", "The phone cannot reach the computer. Coucou may be closed there, its phone link may be off, or it is on another network.")
null -> ""
}
@@ -51,7 +53,8 @@ object LinkHealthText {
fun lines(connected: Boolean, health: LinkHealth, nowMs: Long, wifiUp: Boolean = true): Pair<String, String>? {
val at = health.lostAtMs ?: return null
if (connected) return null
- val head = "Connection lost ${ago(nowMs - at)} ago, reconnecting" + if (health.attempts >= 3) " (${health.attempts} tries)" else ""
+ val head = Texts.t("lost_head", "Connection lost %1\$s ago, reconnecting", ago(nowMs - at)) +
+ if (health.attempts >= 3) " " + Texts.t("lost_tries", "(%1\$d tries)", health.attempts) else ""
return head to why(health.reason, wifiUp)
}
}
@@ -88,9 +91,9 @@ object BatteryHint {
fun steps(samsung: Boolean): List<String> =
if (samsung) listOf(
- "Open Settings > Apps > Coucou for Android > Battery and choose Unrestricted.",
- "Then Settings > Battery > Background usage limits: make sure Coucou is not in Sleeping apps or Deep sleeping apps (add it to Never sleeping apps).",
+ Texts.t("battery_step_samsung_1", "Open Settings > Apps > Coucou for Android > Battery and choose Unrestricted."),
+ Texts.t("battery_step_samsung_2", "Then Settings > Battery > Background usage limits: make sure Coucou is not in Sleeping apps or Deep sleeping apps (add it to Never sleeping apps)."),
) else listOf(
- "Open the app's battery setting and choose Unrestricted (or Don't optimise).",
+ Texts.t("battery_step_generic", "Open the app's battery setting and choose Unrestricted (or Don't optimise)."),
)
}
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index b7d9b682..9ebc6abb 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -201,6 +201,9 @@
<string name="relay_line_unreachable">Cannot reach the relay. Check your internet connection.</string>
<string name="relay_line_away">Your computer is not answering through the relay. It may be asleep or have the relay off.</string>
<string name="settings_section_sound">Sound</string>
+ <string name="settings_language">Language</string>
+ <string name="language_system">System default</string>
+ <string name="language_picker_hint">Pick the language of Coucou. From Android 13 you can also choose it in Android\'s own settings, under Apps.</string>
<string name="settings_theme">Theme</string>
<string name="theme_system">System</string>
<string name="theme_light">Light</string>
@@ -335,4 +338,105 @@
<string name="battery_body">Android pauses background apps to save battery. If requests stop reaching you when the phone is locked, let Coucou run without restrictions. This is only a suggestion.</string>
<string name="battery_open">Open settings</string>
<string name="battery_not_now">Not now</string>
+ <string name="ago_less_than_minute">less than a minute</string>
+ <string name="ago_minutes">%1$d min</string>
+ <string name="ago_hours">%1$d h</string>
+ <string name="ago_hours_minutes">%1$d h %2$d min</string>
+ <string name="lost_silent">The computer stopped answering. This is usual after the phone slept.</string>
+ <string name="lost_closed">The computer closed the connection. Coucou may have been closed or restarted there.</string>
+ <string name="lost_no_wifi">The phone is not on Wi-Fi. Join the network your computer is on, or use the internet link.</string>
+ <string name="lost_unreachable">The phone cannot reach the computer. Coucou may be closed there, its phone link may be off, or it is on another network.</string>
+ <string name="lost_head">Connection lost %1$s ago, reconnecting</string>
+ <string name="lost_tries">(%1$d tries)</string>
+ <string name="battery_step_samsung_1">Open Settings &gt; Apps &gt; Coucou for Android &gt; Battery and choose Unrestricted.</string>
+ <string name="battery_step_samsung_2">Then Settings &gt; Battery &gt; Background usage limits: make sure Coucou is not in Sleeping apps or Deep sleeping apps (add it to Never sleeping apps).</string>
+ <string name="battery_step_generic">Open the app\'s battery setting and choose Unrestricted (or Don\'t optimise).</string>
+ <string name="tool_action_other">do something</string>
+ <string name="tool_a_file">A file</string>
+ <string name="tool_asking">Asking a question</string>
+ <string name="tool_running">Running a command</string>
+ <string name="tool_reading">Reading files</string>
+ <string name="tool_editing">Editing files</string>
+ <string name="tool_searching">Searching files</string>
+ <string name="tool_looking">Looking at files</string>
+ <string name="tool_web_search">Searching the web</string>
+ <string name="tool_web_page">Reading a web page</string>
+ <string name="tool_subagent">Running a sub-agent</string>
+ <string name="tool_planning">Planning</string>
+ <string name="tool_action_ask">ask a question</string>
+ <string name="tool_action_run">run a command</string>
+ <string name="tool_action_read">read files</string>
+ <string name="tool_action_edit">edit files</string>
+ <string name="tool_action_search">search files</string>
+ <string name="tool_action_look">look at files</string>
+ <string name="tool_action_web_search">search the web</string>
+ <string name="tool_action_web_page">read a web page</string>
+ <string name="tool_action_subagent">run a sub-agent</string>
+ <string name="usage_resets_at">resets at %1$s</string>
+ <string name="usage_resets_day">resets %1$s %2$s</string>
+ <string name="usage_resets_date">resets %1$s %2$d %3$s</string>
+ <string name="usage_near_limit">Near limit</string>
+ <string name="widget_waiting_computer">Waiting for your computer</string>
+ <string name="widget_no_agents">No agents running</string>
+ <string name="widget_all_calm">All calm</string>
+ <string name="widget_waiting_pc">Waiting for your PC</string>
+ <string name="widget_nothing_needs_you">Nothing needs you</string>
+ <string name="usage_window_5h">5 h</string>
+ <string name="usage_window_week">week</string>
+ <string name="glance_not_paired">Not paired</string>
+ <string name="glance_not_paired_detail">Open Coucou to connect to your computer</string>
+ <string name="glance_reaching">Reaching your computer</string>
+ <string name="glance_cannot_reach">Coucou cannot reach your computer</string>
+ <string name="glance_waiting_you">Waiting for you</string>
+ <string name="glance_waiting_answer">Waiting for your answer</string>
+ <string name="glance_needs_look">An agent needs a look</string>
+ <string name="glance_one_working">%1$s is working</string>
+ <string name="glance_on">On %1$s</string>
+ <string name="glance_all_done">All done</string>
+ <string name="glance_to">To %1$s</string>
+ <string name="glance_nothing_running">Nothing is running</string>
+ <string name="glance_line_approval">Waiting for your approval</string>
+ <string name="glance_line_limit">Hit a limit</string>
+ <string name="glance_line_dizzy">Needs a look</string>
+ <string name="glance_line_idle">Idle</string>
+ <string name="mood_calm">calm</string>
+ <string name="mood_working">working</string>
+ <string name="mood_thinking">thinking</string>
+ <string name="mood_searching">searching</string>
+ <string name="mood_waiting">waiting for you</string>
+ <string name="mood_question">has a question</string>
+ <string name="mood_error">in trouble</string>
+ <string name="mood_happy">happy</string>
+ <string name="mood_limit">at a limit</string>
+ <string name="mood_asleep">asleep</string>
+ <string name="mood_dizzy">dizzy</string>
+ <string name="home_recent_allowed">Allowed: %1$s</string>
+ <string name="home_recent_denied">Denied: %1$s</string>
+ <string name="agent_an">an agent</string>
+ <string name="home_decision_allowed">You allowed %1$s to %2$s</string>
+ <string name="home_decision_denied">You denied %1$s to %2$s</string>
+ <plurals name="widget_n_waiting">
+ <item quantity="one">%1$d waiting</item>
+ <item quantity="other">%1$d waiting</item>
+ </plurals>
+ <plurals name="glance_requests">
+ <item quantity="one">%1$d request to approve</item>
+ <item quantity="other">%1$d requests to approve</item>
+ </plurals>
+ <plurals name="glance_questions">
+ <item quantity="one">%1$d question from an agent</item>
+ <item quantity="other">%1$d questions from agents</item>
+ </plurals>
+ <plurals name="glance_stopped">
+ <item quantity="one">%1$d agent stopped</item>
+ <item quantity="other">%1$d agents stopped</item>
+ </plurals>
+ <plurals name="glance_working_many">
+ <item quantity="one">%1$d agent is working</item>
+ <item quantity="other">%1$d agents are working</item>
+ </plurals>
+ <plurals name="spoken_waiting_you">
+ <item quantity="one">%1$d waiting for you</item>
+ <item quantity="other">%1$d waiting for you</item>
+ </plurals>
</resources>
diff --git a/android/app/src/main/res/xml/locales_config.xml b/android/app/src/main/res/xml/locales_config.xml
new file mode 100644
index 00000000..ec1bf341
--- /dev/null
+++ b/android/app/src/main/res/xml/locales_config.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generated by android/scripts/gen-strings.mjs. Do not edit. -->
+<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
+ <locale android:name="en" />
+</locale-config>
diff --git a/android/app/src/test/kotlin/com/coucou/android/GenStringsTest.kt b/android/app/src/test/kotlin/com/coucou/android/GenStringsTest.kt
new file mode 100644
index 00000000..ab9484f9
--- /dev/null
+++ b/android/app/src/test/kotlin/com/coucou/android/GenStringsTest.kt
@@ -0,0 +1,111 @@
+package com.coucou.android
+
+import java.io.File
+import java.nio.file.Files
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Assume.assumeTrue
+import org.junit.Before
+import org.junit.Test
+
+/**
+ * The string generator, run on a small made-up project: it writes one folder per language and plurals, and --check refuses a translation
+ * with a missing key, a wrong placeholder or a missing plural form, and a generated file that is stale. Needs Node (CI has it).
+ */
+class GenStringsTest {
+ private val script = File("../scripts/gen-strings.mjs").absolutePath
+
+ @Before fun needsNode() {
+ val ok = runCatching { ProcessBuilder("node", "--version").redirectErrorStream(true).start().also { it.inputStream.readBytes() }.waitFor() == 0 }.getOrDefault(false)
+ assumeTrue("Node is needed to run the generator", ok)
+ }
+
+ private class Result(val code: Int, val output: String)
+
+ private fun run(root: File, vararg args: String): Result {
+ val p = ProcessBuilder(listOf("node", script, "--root", root.path) + args).redirectErrorStream(true).start()
+ val out = p.inputStream.bufferedReader().readText()
+ return Result(p.waitFor(), out)
+ }
+
+ private fun project(
+ fr: String = """{"strings": {"hello": "Bonjour %1${'$'}s", "bye": "Au revoir"}, "plurals": {"items": {"one": "%1${'$'}d élément", "many": "%1${'$'}d d'éléments", "other": "%1${'$'}d éléments"}}}""",
+ extra: Map<String, String> = emptyMap(),
+ ): File {
+ val root = Files.createTempDirectory("gen-strings").toFile()
+ File(root, "i18n/translations").mkdirs()
+ File(root, "i18n/app-strings.json").writeText(
+ """{"_about": "x", "strings": {"hello": "Hello %1${'$'}s", "bye": "Goodbye"}, "plurals": {"items": {"one": "%1${'$'}d item", "other": "%1${'$'}d items"}}}""",
+ )
+ File(root, "i18n/translations/fr.json").writeText(fr)
+ for ((name, text) in extra) File(root, "i18n/translations/$name").writeText(text)
+ return root
+ }
+
+ @Test fun itWritesAFolderPerLanguageWithItsPlurals() {
+ val root = project()
+ val r = run(root)
+ assertEquals(r.output, 0, r.code)
+ val fr = File(root, "app/src/main/res/values-fr/strings.xml").readText()
+ assertTrue(fr.contains("""<string name="hello">Bonjour %1${'$'}s</string>"""))
+ assertTrue(fr.contains("""<item quantity="many">%1${'$'}d d\'éléments</item>"""))
+ val en = File(root, "app/src/main/res/values/strings.xml").readText()
+ assertTrue(en.contains("""<item quantity="one">%1${'$'}d item</item>"""))
+ assertEquals(listOf("en", "fr"), Regex("""android:name="([^"]+)"""").findAll(File(root, "app/src/main/res/xml/locales_config.xml").readText()).map { it.groupValues[1] }.toList())
+ assertEquals(0, run(root, "--check").code)
+ }
+
+ @Test fun aMissingKeyFailsTheCheck() {
+ val root = project(fr = """{"strings": {"hello": "Bonjour %1${'$'}s"}, "plurals": {"items": {"one": "%1${'$'}d a", "many": "%1${'$'}d b", "other": "%1${'$'}d c"}}}""")
+ val r = run(root, "--check")
+ assertEquals(1, r.code)
+ assertTrue(r.output, r.output.contains("""fr: missing string "bye""""))
+ }
+
+ @Test fun aWrongPlaceholderFailsTheCheck() {
+ val root = project(fr = """{"strings": {"hello": "Bonjour %1${'$'}d", "bye": "Au revoir"}, "plurals": {"items": {"one": "%1${'$'}d a", "many": "%1${'$'}d b", "other": "%1${'$'}d c"}}}""")
+ val r = run(root, "--check")
+ assertEquals(1, r.code)
+ assertTrue(r.output, r.output.contains(""""hello" has the placeholders"""))
+ }
+
+ @Test fun aMissingPluralFormFailsTheCheck() {
+ val root = project(fr = """{"strings": {"hello": "Bonjour %1${'$'}s", "bye": "Au revoir"}, "plurals": {"items": {"one": "%1${'$'}d a", "other": "%1${'$'}d c"}}}""")
+ val r = run(root, "--check")
+ assertEquals(1, r.code)
+ assertTrue(r.output, r.output.contains("""plural "items" has no "many" form"""))
+ }
+
+ @Test fun aPluralFormThatTheLanguageDoesNotUseFailsTheCheck() {
+ val zh = """{"strings": {"hello": "你好 %1${'$'}s", "bye": "再见"}, "plurals": {"items": {"one": "%1${'$'}d 个", "other": "%1${'$'}d 个"}}}"""
+ val r = run(project(extra = mapOf("zh-Hans.json" to zh)), "--check")
+ assertEquals(1, r.code)
+ assertTrue(r.output, r.output.contains("""has a "one" form that zh-Hans does not use"""))
+ }
+
+ @Test fun anExtraKeyAndAnUnknownLanguageFailTheCheck() {
+ val extra = """{"strings": {"hello": "Bonjour %1${'$'}s", "bye": "Au revoir", "nope": "Non"}, "plurals": {"items": {"one": "%1${'$'}d a", "many": "%1${'$'}d b", "other": "%1${'$'}d c"}}}"""
+ val r = run(project(fr = extra, extra = mapOf("xx.json" to "{}")), "--check")
+ assertEquals(1, r.code)
+ assertTrue(r.output, r.output.contains(""""nope" is not in app-strings.json"""))
+ assertTrue(r.output, r.output.contains("xx.json: not a language"))
+ }
+
+ @Test fun aStaleGeneratedFileFailsTheCheck() {
+ val root = project()
+ run(root)
+ File(root, "app/src/main/res/values-fr/strings.xml").appendText("<!-- edited by hand -->")
+ val r = run(root, "--check")
+ assertEquals(1, r.code)
+ assertTrue(r.output, r.output.contains("stale: app/src/main/res/values-fr/strings.xml"))
+ }
+
+ @Test fun theReviewListsWhatWasNotTakenFromTheDesktopApps() {
+ val root = project()
+ val r = run(root, "--review")
+ assertEquals(r.output, 0, r.code)
+ val md = File(root, "i18n/REVIEW.md").readText()
+ assertTrue(md.contains("## Français (fr)"))
+ assertTrue(md.contains("`hello`, `bye`"))
+ }
+}
diff --git a/android/app/src/test/kotlin/com/coucou/android/TextsTest.kt b/android/app/src/test/kotlin/com/coucou/android/TextsTest.kt
new file mode 100644
index 00000000..c7bd951a
--- /dev/null
+++ b/android/app/src/test/kotlin/com/coucou/android/TextsTest.kt
@@ -0,0 +1,40 @@
+package com.coucou.android
+
+import com.coucou.android.core.Texts
+import org.junit.After
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class TextsTest {
+ @After fun clean() { Texts.source = null }
+
+ @Test fun englishIsTheFallback() {
+ assertEquals("Running a command", Texts.t("tool_running", "Running a command"))
+ assertEquals("Allowed: edit files", Texts.t("home_recent_allowed", "Allowed: %1\$s", "edit files"))
+ assertEquals("1 request to approve", Texts.n("glance_requests", 1, "%1\$d request to approve", "%1\$d requests to approve"))
+ assertEquals("3 requests to approve", Texts.n("glance_requests", 3, "%1\$d request to approve", "%1\$d requests to approve"))
+ }
+
+ @Test fun aSourceWins() {
+ Texts.source = object : Texts.Source {
+ override fun string(key: String) = if (key == "tool_running") "Exécute une commande" else null
+ override fun plural(key: String, count: Int) = if (key == "glance_requests") (if (count == 1) "%1\$d demande" else "%1\$d demandes") else null
+ }
+ assertEquals("Exécute une commande", Texts.t("tool_running", "Running a command"))
+ assertEquals("Elsewhere", Texts.t("other", "Elsewhere"))
+ assertEquals("2 demandes", Texts.n("glance_requests", 2, "%1\$d request to approve", "%1\$d requests to approve"))
+ assertEquals("1 request", Texts.n("another", 1, "%1\$d request", "%1\$d requests"))
+ }
+
+ @Test fun argumentsAreFilledByPosition() {
+ Texts.source = object : Texts.Source {
+ override fun string(key: String) = "%2\$s a autorisé %1\$s"
+ override fun plural(key: String, count: Int): String? = null
+ }
+ assertEquals("Marie a autorisé Claude", Texts.t("k", "%1\$s was allowed by %2\$s", "Claude", "Marie"))
+ }
+
+ @Test fun aTextWithAPercentSignButNoArgumentIsNotFormatted() {
+ assertEquals("100% done", Texts.t("k", "100% done"))
+ }
+}
diff --git a/android/i18n/app-strings.json b/android/i18n/app-strings.json
index f7e1cf30..c076fa39 100644
--- a/android/i18n/app-strings.json
+++ b/android/i18n/app-strings.json
@@ -201,6 +201,9 @@
"relay_line_unreachable": "Cannot reach the relay. Check your internet connection.",
"relay_line_away": "Your computer is not answering through the relay. It may be asleep or have the relay off.",
"settings_section_sound": "Sound",
+ "settings_language": "Language",
+ "language_system": "System default",
+ "language_picker_hint": "Pick the language of Coucou. From Android 13 you can also choose it in Android's own settings, under Apps.",
"settings_theme": "Theme",
"theme_system": "System",
"theme_light": "Light",
@@ -334,6 +337,91 @@
"battery_title": "Keep the connection while the screen is off",
"battery_body": "Android pauses background apps to save battery. If requests stop reaching you when the phone is locked, let Coucou run without restrictions. This is only a suggestion.",
"battery_open": "Open settings",
- "battery_not_now": "Not now"
+ "battery_not_now": "Not now",
+ "ago_less_than_minute": "less than a minute",
+ "ago_minutes": "%1$d min",
+ "ago_hours": "%1$d h",
+ "ago_hours_minutes": "%1$d h %2$d min",
+ "lost_silent": "The computer stopped answering. This is usual after the phone slept.",
+ "lost_closed": "The computer closed the connection. Coucou may have been closed or restarted there.",
+ "lost_no_wifi": "The phone is not on Wi-Fi. Join the network your computer is on, or use the internet link.",
+ "lost_unreachable": "The phone cannot reach the computer. Coucou may be closed there, its phone link may be off, or it is on another network.",
+ "lost_head": "Connection lost %1$s ago, reconnecting",
+ "lost_tries": "(%1$d tries)",
+ "battery_step_samsung_1": "Open Settings > Apps > Coucou for Android > Battery and choose Unrestricted.",
+ "battery_step_samsung_2": "Then Settings > Battery > Background usage limits: make sure Coucou is not in Sleeping apps or Deep sleeping apps (add it to Never sleeping apps).",
+ "battery_step_generic": "Open the app's battery setting and choose Unrestricted (or Don't optimise).",
+ "tool_action_other": "do something",
+ "tool_a_file": "A file",
+ "tool_asking": "Asking a question",
+ "tool_running": "Running a command",
+ "tool_reading": "Reading files",
+ "tool_editing": "Editing files",
+ "tool_searching": "Searching files",
+ "tool_looking": "Looking at files",
+ "tool_web_search": "Searching the web",
+ "tool_web_page": "Reading a web page",
+ "tool_subagent": "Running a sub-agent",
+ "tool_planning": "Planning",
+ "tool_action_ask": "ask a question",
+ "tool_action_run": "run a command",
+ "tool_action_read": "read files",
+ "tool_action_edit": "edit files",
+ "tool_action_search": "search files",
+ "tool_action_look": "look at files",
+ "tool_action_web_search": "search the web",
+ "tool_action_web_page": "read a web page",
+ "tool_action_subagent": "run a sub-agent",
+ "usage_resets_at": "resets at %1$s",
+ "usage_resets_day": "resets %1$s %2$s",
+ "usage_resets_date": "resets %1$s %2$d %3$s",
+ "usage_near_limit": "Near limit",
+ "widget_waiting_computer": "Waiting for your computer",
+ "widget_no_agents": "No agents running",
+ "widget_all_calm": "All calm",
+ "widget_waiting_pc": "Waiting for your PC",
+ "widget_nothing_needs_you": "Nothing needs you",
+ "usage_window_5h": "5 h",
+ "usage_window_week": "week",
+ "glance_not_paired": "Not paired",
+ "glance_not_paired_detail": "Open Coucou to connect to your computer",
+ "glance_reaching": "Reaching your computer",
+ "glance_cannot_reach": "Coucou cannot reach your computer",
+ "glance_waiting_you": "Waiting for you",
+ "glance_waiting_answer": "Waiting for your answer",
+ "glance_needs_look": "An agent needs a look",
+ "glance_one_working": "%1$s is working",
+ "glance_on": "On %1$s",
+ "glance_all_done": "All done",
+ "glance_to": "To %1$s",
+ "glance_nothing_running": "Nothing is running",
+ "glance_line_approval": "Waiting for your approval",
+ "glance_line_limit": "Hit a limit",
+ "glance_line_dizzy": "Needs a look",
+ "glance_line_idle": "Idle",
+ "mood_calm": "calm",
+ "mood_working": "working",
+ "mood_thinking": "thinking",
+ "mood_searching": "searching",
+ "mood_waiting": "waiting for you",
+ "mood_question": "has a question",
+ "mood_error": "in trouble",
+ "mood_happy": "happy",
+ "mood_limit": "at a limit",
+ "mood_asleep": "asleep",
+ "mood_dizzy": "dizzy",
+ "home_recent_allowed": "Allowed: %1$s",
+ "home_recent_denied": "Denied: %1$s",
+ "agent_an": "an agent",
+ "home_decision_allowed": "You allowed %1$s to %2$s",
+ "home_decision_denied": "You denied %1$s to %2$s"
+ },
+ "plurals": {
+ "widget_n_waiting": {"one": "%1$d waiting", "other": "%1$d waiting"},
+ "glance_requests": {"one": "%1$d request to approve", "other": "%1$d requests to approve"},
+ "glance_questions": {"one": "%1$d question from an agent", "other": "%1$d questions from agents"},
+ "glance_stopped": {"one": "%1$d agent stopped", "other": "%1$d agents stopped"},
+ "glance_working_many": {"one": "%1$d agent is working", "other": "%1$d agents are working"},
+ "spoken_waiting_you": {"one": "%1$d waiting for you", "other": "%1$d waiting for you"}
}
}
diff --git a/android/scripts/gen-strings.mjs b/android/scripts/gen-strings.mjs
index 80f91d0c..9ea278f5 100644
--- a/android/scripts/gen-strings.mjs
+++ b/android/scripts/gen-strings.mjs
@@ -1,13 +1,43 @@
-// Generates app/src/main/res/values/strings.xml from i18n/app-strings.json. The app is English only.
-// Usage: node android/scripts/gen-strings.mjs [--check]
-// --check writes nothing and exits 1 if the committed file is stale.
+// Generates the string resources of the Android app from the English source and the translations:
+// i18n/app-strings.json the English source ("strings" and "plurals")
+// i18n/translations/<tag>.json one file per language: { "strings": {key: text}, "plurals": {key: {category: text}} }
+// app/src/main/res/values/strings.xml, values-<qualifier>/strings.xml, res/xml/locales_config.xml (generated)
+// Usage: node android/scripts/gen-strings.mjs [--check] [--review] [--root <dir>]
+// --check writes nothing; exits 1 if a generated file is stale or a translation is wrong (a missing or extra key, a placeholder that
+// does not match the English one, a missing plural form).
+// --review writes i18n/REVIEW.md: the strings of each language that were written for Coucou for Android and not taken from the Mac and
+// Windows apps (windows/src/i18n/strings.json), so a native speaker can check them.
+// --root work in another folder with the same layout (the tests use it).
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
-const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
-const target = path.join(root, "app/src/main/res/values/strings.xml");
-const app = JSON.parse(fs.readFileSync(path.join(root, "i18n/app-strings.json"), "utf8")).strings;
+const here = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
+const argv = process.argv.slice(2);
+const rootArg = argv.indexOf("--root");
+const root = rootArg >= 0 ? path.resolve(argv[rootArg + 1]) : here;
+const check = argv.includes("--check");
+const review = argv.includes("--review");
+
+// Every language the app can have: the BCP 47 tag, the folder qualifier of its resources, its name in its own language (the picker shows
+// it so a person can find their language whatever the phone speaks), and the plural categories Android needs for it (CLDR).
+export const LANGUAGES = [
+ { tag: "fr", qualifier: "fr", name: "Français", plural: ["one", "many", "other"] },
+ { tag: "es", qualifier: "es", name: "Español", plural: ["one", "many", "other"] },
+ { tag: "pt-BR", qualifier: "pt-rBR", name: "Português (Brasil)", plural: ["one", "many", "other"] },
+ { tag: "zh-Hans", qualifier: "b+zh+Hans", name: "简体中文", plural: ["other"] },
+ { tag: "hi", qualifier: "hi", name: "हिन्दी", plural: ["one", "other"] },
+ { tag: "bn", qualifier: "bn", name: "বাংলা", plural: ["one", "other"] },
+ { tag: "ru", qualifier: "ru", name: "Русский", plural: ["one", "few", "many", "other"] },
+ { tag: "id", qualifier: "in", name: "Bahasa Indonesia", plural: ["other"] },
+ { tag: "ar", qualifier: "ar", name: "العربية", plural: ["zero", "one", "two", "few", "many", "other"] },
+];
+const ENGLISH_PLURAL = ["one", "other"];
+
+const res = path.join(root, "app/src/main/res");
+const source = JSON.parse(fs.readFileSync(path.join(root, "i18n/app-strings.json"), "utf8"));
+const strings = source.strings;
+const plurals = source.plurals ?? {};
const BS = String.fromCharCode(92);
const esc = (s) =>
@@ -17,20 +47,122 @@ const esc = (s) =>
.replace(/^([@?])/, BS + "$1");
// Placeholders must be positional printf arguments (%1$s), not {name}.
-if (Object.values(app).some((v) => /\{\w+\}/.test(v))) {
+const everyText = [...Object.values(strings), ...Object.values(plurals).flatMap((p) => Object.values(p))];
+if (everyText.some((v) => /\{\w+\}/.test(v))) {
console.error("Placeholders are not supported; use %1$s in app-strings.json.");
process.exit(2);
}
-const xml =
- `<?xml version="1.0" encoding="utf-8"?>\n<!-- Generated by android/scripts/gen-strings.mjs. Do not edit. -->\n<resources>\n` +
- Object.entries(app).map(([k, v]) => ` <string name="${k}">${esc(v)}</string>`).join("\n") + `\n</resources>\n`;
+/** The placeholders of a text as a sorted list ("%1$d", "%2$s", "%%"), so two texts can be compared whatever the word order. */
+const placeholders = (s) => (s.match(/%(?:\d+\$)?[sd%]/g) ?? []).sort().join(" ");
+
+const xml = (body) => `<?xml version="1.0" encoding="utf-8"?>\n<!-- Generated by android/scripts/gen-strings.mjs. Do not edit. -->\n<resources>\n${body}\n</resources>\n`;
+const stringLines = (map) => Object.entries(map).map(([k, v]) => ` <string name="${k}">${esc(v)}</string>`);
+const pluralBlocks = (map, order) =>
+ Object.entries(map).map(([k, forms]) =>
+ ` <plurals name="${k}">\n` +
+ order.filter((c) => forms[c] !== undefined).map((c) => ` <item quantity="${c}">${esc(forms[c])}</item>`).join("\n") +
+ `\n </plurals>`);
+const ALL = ["zero", "one", "two", "few", "many", "other"];
+
+const outputs = new Map(); // path -> content
+outputs.set(path.join(res, "values/strings.xml"), xml([...stringLines(strings), ...pluralBlocks(plurals, ALL)].join("\n")));
+
+// The words of the pure rules are looked up by key at run time. A table of static references (R.string.x) lets the resource shrinker see
+// that every string is used, which a lookup by name would hide from it.
+outputs.set(
+ path.join(root, "app/src/main/kotlin/com/coucou/android/app/TextIds.kt"),
+ `// Generated by android/scripts/gen-strings.mjs. Do not edit.\npackage com.coucou.android.app\n\nimport com.coucou.android.R\n\n` +
+ `/** Every string and plural of the app by key, for core/Texts.kt (static references, so the shrinker keeps them). */\ninternal object TextIds {\n` +
+ ` val strings: Map<String, Int> = mapOf(\n${Object.keys(strings).map((k) => ` "${k}" to R.string.${k},`).join("\n")}\n )\n\n` +
+ ` val plurals: Map<String, Int> = mapOf(\n${Object.keys(plurals).map((k) => ` "${k}" to R.plurals.${k},`).join("\n")}\n )\n}\n`,
+);
+
+const problems = [];
+const found = [];
+const dir = path.join(root, "i18n/translations");
+if (fs.existsSync(dir)) {
+ for (const file of fs.readdirSync(dir).filter((f) => f.endsWith(".json")).sort()) {
+ const tag = file.replace(/\.json$/, "");
+ const lang = LANGUAGES.find((l) => l.tag === tag);
+ if (!lang) { problems.push(`${file}: not a language the app knows (see LANGUAGES in gen-strings.mjs)`); continue; }
+ found.push(lang);
+ const t = JSON.parse(fs.readFileSync(path.join(dir, file), "utf8"));
+ const ts = t.strings ?? {};
+ const tp = t.plurals ?? {};
+ for (const k of Object.keys(strings)) {
+ if (typeof ts[k] !== "string" || ts[k] === "") problems.push(`${tag}: missing string "${k}"`);
+ else if (placeholders(ts[k]) !== placeholders(strings[k])) problems.push(`${tag}: "${k}" has the placeholders [${placeholders(ts[k])}], the English has [${placeholders(strings[k])}]`);
+ }
+ for (const k of Object.keys(ts)) if (!(k in strings)) problems.push(`${tag}: "${k}" is not in app-strings.json`);
+ for (const [k, en] of Object.entries(plurals)) {
+ const forms = tp[k];
+ if (!forms) { problems.push(`${tag}: missing plural "${k}"`); continue; }
+ for (const c of lang.plural) {
+ if (typeof forms[c] !== "string" || forms[c] === "") problems.push(`${tag}: plural "${k}" has no "${c}" form`);
+ else if (placeholders(forms[c]) !== placeholders(en.other)) problems.push(`${tag}: plural "${k}" form "${c}" has the placeholders [${placeholders(forms[c])}], the English has [${placeholders(en.other)}]`);
+ }
+ for (const c of Object.keys(forms)) if (!lang.plural.includes(c)) problems.push(`${tag}: plural "${k}" has a "${c}" form that ${tag} does not use`);
+ }
+ for (const k of Object.keys(tp)) if (!(k in plurals)) problems.push(`${tag}: plural "${k}" is not in app-strings.json`);
+ const ordered = Object.fromEntries(Object.keys(strings).filter((k) => ts[k] !== undefined).map((k) => [k, ts[k]]));
+ const orderedPlurals = Object.fromEntries(Object.keys(plurals).filter((k) => tp[k] !== undefined).map((k) => [k, tp[k]]));
+ outputs.set(path.join(res, `values-${lang.qualifier}/strings.xml`), xml([...stringLines(ordered), ...pluralBlocks(orderedPlurals, lang.plural)].join("\n")));
+ }
+}
+
+// The languages the system picker may offer: English and every language with a translation file.
+const localeTags = ["en", ...LANGUAGES.filter((l) => found.includes(l)).map((l) => l.tag)];
+outputs.set(
+ path.join(res, "xml/locales_config.xml"),
+ `<?xml version="1.0" encoding="utf-8"?>\n<!-- Generated by android/scripts/gen-strings.mjs. Do not edit. -->\n<locale-config xmlns:android="http://schemas.android.com/apk/res/android">\n` +
+ localeTags.map((t) => ` <locale android:name="${t}" />`).join("\n") + `\n</locale-config>\n`,
+);
+
+// Folders of languages that no longer have a translation file must go (check mode reports them).
+const staleDirs = fs.existsSync(res)
+ ? fs.readdirSync(res).filter((d) => d.startsWith("values-") && !["values-notnight"].includes(d) && !outputs.has(path.join(res, d, "strings.xml")) && fs.existsSync(path.join(res, d, "strings.xml")))
+ : [];
+
+if (review) {
+ const windowsFile = path.join(root, "../windows/src/i18n/strings.json");
+ const windows = fs.existsSync(windowsFile) ? JSON.parse(fs.readFileSync(windowsFile, "utf8")).strings : {};
+ let md = "# Translations to check\n\nGenerated by `node android/scripts/gen-strings.mjs --review`. Every string below was written for Coucou for Android, by a machine, and has not been\n" +
+ "read by a native speaker. The strings that match the Mac and Windows apps' own wording (windows/src/i18n/strings.json) are not listed: they are\n" +
+ "Louis's. A fix is a change to the language's file in `i18n/translations/`, then `node android/scripts/gen-strings.mjs`.\n";
+ for (const lang of LANGUAGES.filter((l) => found.includes(l))) {
+ const t = JSON.parse(fs.readFileSync(path.join(dir, `${lang.tag}.json`), "utf8"));
+ const keys = Object.keys(strings).filter((k) => {
+ const w = windows[strings[k]]?.[lang.tag];
+ return !(w && w === t.strings?.[k]);
+ });
+ md += `\n## ${lang.name} (${lang.tag})\n\n${keys.length} of ${Object.keys(strings).length} strings and ${Object.keys(plurals).length} plural groups.\n\n` + (keys.length ? "`" + keys.join("`, `") + "`\n" : "");
+ }
+ fs.writeFileSync(path.join(root, "i18n/REVIEW.md"), md);
+ console.log("i18n/REVIEW.md");
+ process.exit(0);
+}
-if (process.argv.includes("--check")) {
- // Windows checkouts may turn LF into CRLF; the content is what matters.
- const stale = !fs.existsSync(target) || fs.readFileSync(target, "utf8").replace(/\r\n/g, "\n") !== xml;
- if (stale) console.error(`stale: ${path.relative(root, target)}`);
- process.exit(stale ? 1 : 0);
+if (check) {
+ for (const [file, content] of outputs) {
+ // Windows checkouts may turn LF into CRLF; the content is what matters.
+ const stale = !fs.existsSync(file) || fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n") !== content;
+ if (stale) problems.push(`stale: ${path.relative(root, file)}`);
+ }
+ for (const d of staleDirs) problems.push(`stale: app/src/main/res/${d} has no translation file`);
+ if (problems.length) {
+ for (const p of problems) console.error(p);
+ process.exit(1);
+ }
+ process.exit(0);
+}
+
+if (problems.length) {
+ for (const p of problems) console.error(p);
+ process.exit(1);
+}
+for (const [file, content] of outputs) {
+ fs.mkdirSync(path.dirname(file), { recursive: true });
+ fs.writeFileSync(file, content);
}
-fs.writeFileSync(target, xml);
-console.log(`${Object.keys(app).length} strings`);
+console.log(`${Object.keys(strings).length} strings, ${Object.keys(plurals).length} plurals, ${found.length} translations`);