Commit Graph
189 Commits
Author SHA1 Message Date
David Sangrey 99709c0146 [#2444] Invert Link Opener Priority 2026-01-07 21:52:14 -05:00
David Sangrey beb68efae8 [2568] Fix Ships JSON Typo 2025-12-25 01:36:24 -05:00
David Sangrey 2041b3d3d3 [Minor] Update Type Hints and Alias Usages 2025-12-01 22:04:28 -05:00
Inutt 9fd04e5c02 Add localisation of stations names
This currently only affects system colonisation ships, which have '$EXT_PANEL_ColonisationShip;' in their StationName
entries in the journal. Other strings may need to be added in future.

Fixes #2404
diff --git a/L10n/en.template b/L10n/en.template
index faac3259..f670e39c 100644
--- a/L10n/en.template
+++ b/L10n/en.template
@@ -839,3 +839,9 @@

 /* edastro_core.py: Settings>EDAstro - Label on checkbox for 'send data'; */
 "Send data to EDAstro" = "Send data to EDAstro";
+
+/* common_coreutils.py: Colonisation ship name, with title; In files: common_coreutils.py:81:81 */
+"System Colonisation Ship {NAME}" = "System Colonisation Ship {NAME}";
+
+/* common_coreutils.py: Unidentified colonisation ship; In files: common_coreutils.py:84:84 */
+"System Colonisation Ship" = "System Colonisation Ship";
diff --git a/plugins/common_coreutils.py b/plugins/common_coreutils.py
index 6b90d4dc..a488de46 100644
--- a/plugins/common_coreutils.py
+++ b/plugins/common_coreutils.py
@@ -29,6 +29,7 @@ import gzip
 import io
 import json
 import os
+import re
 import myNotebook as nb  # noqa: N813
 from EDMCLogging import get_main_logger
 from companion import CAPIData
@@ -47,6 +48,49 @@ SEPY = 10  # seperator line spacing
 STATION_UNDOCKED = '×'  # "Station" name to display when not docked = U+00D7

+# Known colonisation ship names match one of the following:
+#   "$EXT_PANEL_ColonisationShip;"
+#   "$EXT_PANEL_ColonisationShip; <ship name>" with "<ship name>" being eg; "Okawara Horizons"
+#   "$EXT_PANEL_ColonisationShip:#index=<number>;"
+#   "$EXT_PANEL_ColonisationShip:#index=<number>; <ship name>"
+_RE_COLONISATION_SHIP = re.compile(r'\$EXT_PANEL_ColonisationShip(?::#index=(\d+))?;(?: (.+))?')
+
+
+def localised_name(value: str | None) -> str | None:
+    """
+    Handle localisation of strings in places like station names.
+
+    This is currently an issue for system colonisation ships that have a station name along the
+    lines of "$EXT_PANEL_ColonisationShip; Okawara Horizons" when written to the journal, but would
+    be better displayed as "System Colonisation Ship Okawara Horizona" (or other appropriately
+    localised equivalent).
+
+    If no (known) localisable strings are present, the input will be returned unmodified.
+
+    :param value: The non-localised string.
+    :return: The localised string, or None if the input was None.
+    """
+    if value is None:
+        return None
+
+    colonisation_ship_match = _RE_COLONISATION_SHIP.match(value)
+    if colonisation_ship_match:
+        ship_index = colonisation_ship_match.group(1)
+        ship_name = colonisation_ship_match.group(2)
+        # Use the ship's index as its name if no name was provided.
+        ship_id = ship_name or ship_index
+
+        if ship_id:
+            # LANG: Colonisation ship name, with title
+            value = tr.tl("System Colonisation Ship {NAME}").format(NAME=ship_id)
+
+        else:
+            # LANG: Unidentified colonisation ship
+            value = tr.tl("System Colonisation Ship")
+
+    return value
+
+
 def plugin_start3(plugin_dir: str) -> str:
     """
     Start the plugin.
@@ -121,7 +165,7 @@ def station_link_common(data: CAPIData, this):
     :param this: The module global from the calling module.
     """
     if data['commander']['docked'] or this.on_foot and this.station_name:
-        this.station_link['text'] = this.station_name
+        this.station_link['text'] = localised_name(this.station_name)
     elif data['lastStarport']['name'] and data['lastStarport']['name'] != "":
         this.station_link['text'] = STATION_UNDOCKED
     else:
@@ -163,12 +207,14 @@ def station_name_setter_common(this):
     :param this: The module global from the calling module.
     """
     to_set: str = cast(str, this.station_name)
+
     if not to_set:
         if this.system_population is not None and this.system_population > 0:
             to_set = STATION_UNDOCKED
         else:
             to_set = ''

+    to_set = str(localised_name(to_set))
     this.station_link['text'] = to_set

diff --git a/plugins/edsm.py b/plugins/edsm.py
index e1e6b168..902e248b 100644
--- a/plugins/edsm.py
+++ b/plugins/edsm.py
@@ -43,7 +43,7 @@ from ttkHyperlinkLabel import HyperlinkLabel
 from l10n import translations as tr
 from plugins.common_coreutils import (api_keys_label_common, PADX, PADY, BUTTONX, SEPY, BOXY, STATION_UNDOCKED,
                                       show_pwd_var_common, station_link_common, this_format_common,
-                                      cmdr_data_initial_common)
+                                      cmdr_data_initial_common, localised_name)

 # TODO:
@@ -543,7 +543,7 @@ entry: {entry!r}'''
                 to_set = ''

         if this.station_link:
-            this.station_link['text'] = to_set
+            this.station_link['text'] = localised_name(to_set)
             this.station_link['url'] = station_url(str(this.system_name), str(this.station_name))
             this.station_link.update_idletasks()
2025-11-29 01:25:19 +00:00
David Sangrey 03cbe85535 [2116] A Few More Hand-Overs 2025-11-11 23:17:02 -05:00
David Sangrey 26f06b7bf0 [#2406] Consolidate Modules 2025-04-13 13:42:06 -04:00
David Sangrey eece4c2ba7 [2232] Set EDSM Settings 2024-05-12 23:18:24 -04:00
David Sangrey ad16f0666d [2232] Fix Missing Preferences
Fixes an issue that could present on clean installs where the EDSM keys weren't generated properly.

When the heck did this bug get introduced???
2024-05-12 23:16:45 -04:00
David Sangrey 080d9f98f2 [1812] Handover Translations 2024-04-22 17:33:28 -04:00
David Sangrey dd5e3812a7 [2186] Refine macOS to preserve ContextMenu 2024-04-13 14:44:44 -04:00
David Sangrey d9c7a79155 [Minor] Update Type Hintings
No Content Changes, Shuts Up MyPy
2024-04-06 16:59:49 -04:00
David Sangrey c1b8533cb4 [2186] Simplify myNB Files 2024-03-27 21:22:35 -04:00
David Sangrey f318b3256b [662] Apply Rate Limit 2024-01-04 19:17:21 -05:00
David Sangrey c511b51003 [Translations] Update Translation Template 2023-12-06 17:41:22 -05:00
David Sangrey e2285729df Merge pull request #2086 from GLWine/develop
Fixed translation hook in EDSM.py and Inara.py
2023-12-06 17:17:39 -05:00
David Sangrey 173c32f314 [Minor] Update Code Checks 2023-12-06 17:15:46 -05:00
Phoebe ed163ddb61 [Minor] Typos and mypy 2023-11-17 22:40:08 +01:00
Phoebe 71ff00ce58 [1490] Adds spansh as a URL provider
- Adds a spansh plugin as a URL provider for systems and stations.
- Adds plugin path to build.py.
- Updates a comment in the EDSM plugin.
2023-11-17 16:05:27 -05:00
David Sangrey 6c06600f21 Merge pull request #2096 from HullSeals/fix/2088/fix-and-standardize-UI
Fix and standardize Settings UI
2023-11-16 21:42:41 -05:00
Phoebe a3c1763f4a [2095] Standardize horizontal Padding
- Standardizes horizontal Padding.
- Fixes further padding issues.
- Part of #2095
2023-11-17 03:05:42 +01:00
Phoebe 8063cf099b [2095] Standardize vertical Padding
- Standardizes vertical Padding.
- Fixes issues with the disabled and outdated Plugin list.
- Part of #2095
2023-11-17 01:39:52 +01:00
David Sangrey 93619e4565 [2051] Fix Localized Strings 2023-11-16 18:18:10 -05:00
Phoebe 07ae14be5a [2088] fix UI bugs, introduce standard
- Fixes #2088 and #2089.
- Adds usage of ``row=`` for ``.grid()`` for all config entries in included plugins.
- Changes all config pages to start at row 0.
- Starts introducing a standard for config panel layouts.
2023-11-16 22:21:57 +01:00
David Sangrey 070a3989a0 [2051] Prevent Typing Reversion
Thanks to @norohind for catching this one! I'm not up to date on my PEP585.
2023-11-10 11:33:04 -05:00
Giampiero 98e9765391 Fixed translation hook line 355
Corrected the text of code line 355;
The text text="Show API Key" cannot be translated as indicated, so I rewrote it as text=_('Show API Key').
2023-10-31 01:31:29 +01:00
David Sangrey 2c803d7f4c [2051] Core Plugin Audit
Broken out of #2068
2023-10-19 17:44:33 -04:00
David Sangrey db73b9d775 #2047 Suppress Inaccurate MyPy 2023-08-03 17:33:23 -04:00
David Sangrey d88bd70055 #2047 Mask API Keys in Default Plugins 2023-08-03 16:32:59 -04:00
David Sangrey 247d632cc6 #2040 First Pass - Update Build System 2023-07-26 22:49:03 -04:00
Athanasius 3fb372fb11 EDSM: Remove actually un-necessary, and bug-inducing "not None" checks
I would have added these during a mypy cleanup, but it turns out they're both
not necessary *and* it actually prevents the EDSM Settings tab from properly
populating.
2023-01-22 13:09:34 +00:00
Athanasius c396a253f8 plugins/edsm: Use state[...] values for system/station
* Also renamed system -> system_name and station -> station_name
2023-01-11 19:44:46 +00:00
Athanasius 7d4118738b Add some missing LANG comments, as per script output 2023-01-03 11:46:27 +00:00
Athanasius 0fd835e9ac core plugins: A little more 'children' fixup
* eddn: Needs to find status text, although really there should be a helper
  function for this.
* Removed commented out references to same in edsm and inara.
2022-12-31 16:49:29 +00:00
Athanasius f2de70bad6 core plugins: Use nametowidget() to find system/station widgets
As we're experimenting with per-plugin frames up a level `parent.children`
would need to be `parent.parent.children`, but this way it will Just Work
without knowledge of the hierarchy.
2022-12-31 16:27:22 +00:00
Athanasius 71cbfb8358 plugins/edsm: Lots of type fixing, inc. conditionals where None is possible 2022-12-23 14:47:23 +00:00
Athanasius ba81d95c1e plugins/edsm: Align comments and docstrings with plugins/eddb 2022-12-04 16:12:58 +00:00
Athanasius abe13176e7 EDSM: Timed latch for notifying about Legacy galaxy data
This avoids the spam from EDSM itself objecting to the passed gameversion.
We don't even send anything but Live data now.
2022-12-01 18:00:47 +00:00
Athanasius a581d889fe edsm: Add a paranoia check for changed gameversion
* In theory we would always see `Fileheader` and clear `pending[]`, but let's
  be extra paranoid and also clear it if there's a gameversion/build difference
  between the prior event and the current one.
2022-11-28 12:18:10 +00:00
Athanasius 5743fd3803 edsm: Push gameversion/build into the queue to ensure correctness
1. Due to the _TIMEOUT on the actual `post()` of a message it would be
  possible for new entries to get queued in the meantime.  These queued
  entries could be 'in session' and end up going through pending and thus
  sent before one of the 'new session' events is detected so as to clear
  pending.  The `this.gameversion/build` could have changed in the meantime,
  so are no longer correct if game client changed.
2. So, pass in the current gameversion/build when a message is pushed into
  the queue, and parse those back out when they're pulled out of the queue.
3. Use those versions in the message, not `this.` versions.
2022-11-28 11:04:51 +00:00
Athanasius ad95041605 edsm: Send gameversion/build in all messages
* Record the 'state' version of these in `this`.
* Use those when constructing the message.
* NB: Need to check if messages can be retained in the queue across client
  changes.  Coming up ....
2022-11-28 10:51:25 +00:00
Chris Henning e8b8cf81d5 Change EDSM credentials() to log API keys under a different trace #1496 2022-06-12 17:51:38 -04:00
Athanasius ac7cfb9b14 core plugins: Add big obvious comment about imports and windows installer 2022-02-01 14:45:30 +00:00
Athanasius 4ab6d62926 user_agent: Set this once in config.py and use it everywhere
* Also flake8/mypy pass on timeout_session.py
2021-11-29 18:04:56 +00:00
Athanasius 2fd72fde8e EDSM: Set custom User-Agent for requests session 2021-11-29 17:51:19 +00:00
A_D dac13216a0 remove uneeded cast and fix bug in passed data 2021-08-19 20:51:23 +02:00
A_D f62f1ee97b made types consistent and generic 2021-08-19 20:37:39 +02:00
A_D a37b1882db fixed import order 2021-08-19 20:37:35 +02:00
A_D 1712390732 removed old comment 2021-08-19 20:37:31 +02:00
A_D 78fa629fbe updated edsm 2021-08-19 20:37:26 +02:00
norohind 1581a3bdd7 plugins/edsm.py: fix exception on logger.trace_on, wrong datatype to subtitle 2021-08-17 13:54:38 +03:00