android-localisation 1.1.1__tar.gz → 1.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {android_localisation-1.1.1/android_localisation.egg-info → android_localisation-1.1.2}/PKG-INFO +21 -1
  2. {android_localisation-1.1.1 → android_localisation-1.1.2}/README.md +20 -0
  3. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation/__init__.py +1 -1
  4. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation/cli.py +12 -2
  5. android_localisation-1.1.2/android_localisation/updates.py +95 -0
  6. {android_localisation-1.1.1 → android_localisation-1.1.2/android_localisation.egg-info}/PKG-INFO +21 -1
  7. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation.egg-info/SOURCES.txt +1 -0
  8. {android_localisation-1.1.1 → android_localisation-1.1.2}/pyproject.toml +1 -1
  9. {android_localisation-1.1.1 → android_localisation-1.1.2}/LICENSE +0 -0
  10. {android_localisation-1.1.1 → android_localisation-1.1.2}/MANIFEST.in +0 -0
  11. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation/fix.py +0 -0
  12. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation/java/VerifyStrings.java +0 -0
  13. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation/resources.py +0 -0
  14. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation/translate.py +0 -0
  15. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation/verify.py +0 -0
  16. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation.egg-info/dependency_links.txt +0 -0
  17. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation.egg-info/entry_points.txt +0 -0
  18. {android_localisation-1.1.1 → android_localisation-1.1.2}/android_localisation.egg-info/top_level.txt +0 -0
  19. {android_localisation-1.1.1 → android_localisation-1.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-localisation
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: Zero-dependency Android strings.xml translation and verification using LLMs (Gemini, OpenAI, Anthropic, Ollama).
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/BharathKmalviya/android-llm-localization
@@ -56,6 +56,24 @@ Requires Python 3.8+. No other dependencies.
56
56
 
57
57
  CLI output uses UTF-8, including when redirected to a file or pipe on Windows.
58
58
 
59
+ ### Update notices
60
+
61
+ Interactive `android-localise` commands check PyPI for a newer stable release in
62
+ the background, at most once every 24 hours. When available, a note on stderr
63
+ shows `pip install --upgrade android-localisation`. The CLI never waits for the
64
+ lookup or installs an update automatically. A first short command may finish
65
+ before the lookup completes; a notice appears when a check completes during a
66
+ command or a later invocation can use its cached result.
67
+
68
+ Checks are skipped for help/version output, CI (`CI` set), redirected output and
69
+ pipes. Set `ANDROID_LOCALISE_NO_UPDATE_CHECK=1` to disable them, including when
70
+ using a local model offline. Lookup or cache failures stay silent and do not
71
+ change command exit codes. The small cache lives under
72
+ `%LOCALAPPDATA%/android-localisation` on Windows, or
73
+ `${XDG_CACHE_HOME:-~/.cache}/android-localisation` elsewhere. Only the package's
74
+ public release metadata is requested; API keys and Android resources are never
75
+ included.
76
+
59
77
  ---
60
78
 
61
79
  ## Quick start
@@ -289,6 +307,8 @@ android-localise translate
289
307
  | `OPENAI_API_KEY` | `--provider openai` and `--provider custom` |
290
308
  | `ANTHROPIC_API_KEY` | `--provider anthropic` |
291
309
  | `API_KEY` | fallback for any provider if the provider-specific var is not set |
310
+ | `ANDROID_LOCALISE_NO_UPDATE_CHECK` | Set to `1` to disable update checks/notices |
311
+ | `CI` | When nonempty, skips update checks/notices |
292
312
 
293
313
  ---
294
314
 
@@ -28,6 +28,24 @@ Requires Python 3.8+. No other dependencies.
28
28
 
29
29
  CLI output uses UTF-8, including when redirected to a file or pipe on Windows.
30
30
 
31
+ ### Update notices
32
+
33
+ Interactive `android-localise` commands check PyPI for a newer stable release in
34
+ the background, at most once every 24 hours. When available, a note on stderr
35
+ shows `pip install --upgrade android-localisation`. The CLI never waits for the
36
+ lookup or installs an update automatically. A first short command may finish
37
+ before the lookup completes; a notice appears when a check completes during a
38
+ command or a later invocation can use its cached result.
39
+
40
+ Checks are skipped for help/version output, CI (`CI` set), redirected output and
41
+ pipes. Set `ANDROID_LOCALISE_NO_UPDATE_CHECK=1` to disable them, including when
42
+ using a local model offline. Lookup or cache failures stay silent and do not
43
+ change command exit codes. The small cache lives under
44
+ `%LOCALAPPDATA%/android-localisation` on Windows, or
45
+ `${XDG_CACHE_HOME:-~/.cache}/android-localisation` elsewhere. Only the package's
46
+ public release metadata is requested; API keys and Android resources are never
47
+ included.
48
+
31
49
  ---
32
50
 
33
51
  ## Quick start
@@ -261,6 +279,8 @@ android-localise translate
261
279
  | `OPENAI_API_KEY` | `--provider openai` and `--provider custom` |
262
280
  | `ANTHROPIC_API_KEY` | `--provider anthropic` |
263
281
  | `API_KEY` | fallback for any provider if the provider-specific var is not set |
282
+ | `ANDROID_LOCALISE_NO_UPDATE_CHECK` | Set to `1` to disable update checks/notices |
283
+ | `CI` | When nonempty, skips update checks/notices |
264
284
 
265
285
  ---
266
286
 
@@ -2,4 +2,4 @@
2
2
  android-localisation: Zero-dependency Android strings.xml translation using LLMs.
3
3
  """
4
4
 
5
- __version__ = "1.1.1"
5
+ __version__ = "1.1.2"
@@ -13,7 +13,7 @@ import sys
13
13
  from android_localisation import __version__
14
14
 
15
15
 
16
- def main():
16
+ def main(args=None):
17
17
  for stream in (sys.stdout, sys.stderr):
18
18
  if hasattr(stream, "reconfigure"):
19
19
  stream.reconfigure(encoding="utf-8", errors="replace")
@@ -57,8 +57,18 @@ def main():
57
57
  models_parser.add_argument("--provider", choices=["gemini", "openai", "anthropic"], default=None,
58
58
  help="Filter by provider (shows all if not set)")
59
59
 
60
- args = parser.parse_args()
60
+ if args is None or isinstance(args, list):
61
+ args = parser.parse_args(args)
61
62
 
63
+ from android_localisation.updates import start_update_check, show_update_notice
64
+ update_state = start_update_check()
65
+ try:
66
+ return _run_command(args)
67
+ finally:
68
+ show_update_notice(update_state)
69
+
70
+
71
+ def _run_command(args):
62
72
  if args.command == "translate":
63
73
  from android_localisation.translate import main as run
64
74
  return run(args)
@@ -0,0 +1,95 @@
1
+ """Best-effort release notices for interactive CLI sessions."""
2
+
3
+ import json
4
+ import os
5
+ from pathlib import Path
6
+ import re
7
+ import sys
8
+ import threading
9
+ import time
10
+ import urllib.request
11
+
12
+ from android_localisation import __version__
13
+ from android_localisation.resources import atomic_write
14
+
15
+ CHECK_INTERVAL = 24 * 60 * 60
16
+ PYPI_URL = "https://pypi.org/pypi/android-localisation/json"
17
+
18
+
19
+ def _stable_version(value):
20
+ # This package releases semantic versions; never advertise prereleases.
21
+ if not isinstance(value, str) or not re.fullmatch(r"[0-9]{1,6}\.[0-9]{1,6}\.[0-9]{1,6}", value):
22
+ return None
23
+ return tuple(int(part) for part in value.split("."))
24
+
25
+
26
+ def _cache_path():
27
+ if os.name == "nt":
28
+ base = os.environ.get("LOCALAPPDATA") or str(Path.home() / "AppData" / "Local")
29
+ else:
30
+ base = os.environ.get("XDG_CACHE_HOME") or str(Path.home() / ".cache")
31
+ return Path(base) / "android-localisation" / "update.json"
32
+
33
+
34
+ def start_update_check():
35
+ """Return notice state; refresh in a daemon thread without waiting for network."""
36
+ try:
37
+ if os.environ.get("ANDROID_LOCALISE_NO_UPDATE_CHECK") or os.environ.get("CI"):
38
+ return None
39
+ if not sys.stdout.isatty() or not sys.stderr.isatty():
40
+ return None
41
+ if _stable_version(__version__) is None:
42
+ return None
43
+ path = _cache_path()
44
+ now = time.time()
45
+ state = {"latest": None}
46
+ try:
47
+ cached = json.loads(path.read_text(encoding="utf-8"))
48
+ if _stable_version(cached.get("latest")):
49
+ state["latest"] = cached["latest"]
50
+ checked = cached.get("checked_at")
51
+ if isinstance(checked, (int, float)) and 0 <= now - checked < CHECK_INTERVAL:
52
+ return state
53
+ except (OSError, ValueError, TypeError, AttributeError):
54
+ pass
55
+
56
+ def refresh():
57
+ try:
58
+ request = urllib.request.Request(
59
+ PYPI_URL,
60
+ headers={"User-Agent": "android-localisation/{}".format(__version__)},
61
+ )
62
+ with urllib.request.urlopen(request, timeout=1) as response:
63
+ payload = json.loads(response.read(512 * 1024).decode("utf-8"))
64
+ latest = payload["info"]["version"]
65
+ if _stable_version(latest):
66
+ state["latest"] = latest
67
+ except Exception:
68
+ # Offline, malformed replies and lookup failures never affect commands.
69
+ pass
70
+ try:
71
+ path.parent.mkdir(parents=True, exist_ok=True)
72
+ atomic_write(str(path), json.dumps({"checked_at": now, "latest": state["latest"]}))
73
+ except Exception:
74
+ pass
75
+
76
+ threading.Thread(target=refresh, name="release-check", daemon=True).start()
77
+ return state
78
+ except Exception:
79
+ return None
80
+
81
+
82
+ def show_update_notice(state):
83
+ """Print only a completed/cached check, preserving stdout and exit status."""
84
+ try:
85
+ latest = state.get("latest") if state else None
86
+ available = _stable_version(latest)
87
+ installed = _stable_version(__version__)
88
+ if available and installed and available > installed:
89
+ print(
90
+ "\nUpdate available: android-localisation {} (installed {}).\n"
91
+ "Upgrade: pip install --upgrade android-localisation".format(latest, __version__),
92
+ file=sys.stderr,
93
+ )
94
+ except Exception:
95
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: android-localisation
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: Zero-dependency Android strings.xml translation and verification using LLMs (Gemini, OpenAI, Anthropic, Ollama).
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/BharathKmalviya/android-llm-localization
@@ -56,6 +56,24 @@ Requires Python 3.8+. No other dependencies.
56
56
 
57
57
  CLI output uses UTF-8, including when redirected to a file or pipe on Windows.
58
58
 
59
+ ### Update notices
60
+
61
+ Interactive `android-localise` commands check PyPI for a newer stable release in
62
+ the background, at most once every 24 hours. When available, a note on stderr
63
+ shows `pip install --upgrade android-localisation`. The CLI never waits for the
64
+ lookup or installs an update automatically. A first short command may finish
65
+ before the lookup completes; a notice appears when a check completes during a
66
+ command or a later invocation can use its cached result.
67
+
68
+ Checks are skipped for help/version output, CI (`CI` set), redirected output and
69
+ pipes. Set `ANDROID_LOCALISE_NO_UPDATE_CHECK=1` to disable them, including when
70
+ using a local model offline. Lookup or cache failures stay silent and do not
71
+ change command exit codes. The small cache lives under
72
+ `%LOCALAPPDATA%/android-localisation` on Windows, or
73
+ `${XDG_CACHE_HOME:-~/.cache}/android-localisation` elsewhere. Only the package's
74
+ public release metadata is requested; API keys and Android resources are never
75
+ included.
76
+
59
77
  ---
60
78
 
61
79
  ## Quick start
@@ -289,6 +307,8 @@ android-localise translate
289
307
  | `OPENAI_API_KEY` | `--provider openai` and `--provider custom` |
290
308
  | `ANTHROPIC_API_KEY` | `--provider anthropic` |
291
309
  | `API_KEY` | fallback for any provider if the provider-specific var is not set |
310
+ | `ANDROID_LOCALISE_NO_UPDATE_CHECK` | Set to `1` to disable update checks/notices |
311
+ | `CI` | When nonempty, skips update checks/notices |
292
312
 
293
313
  ---
294
314
 
@@ -7,6 +7,7 @@ android_localisation/cli.py
7
7
  android_localisation/fix.py
8
8
  android_localisation/resources.py
9
9
  android_localisation/translate.py
10
+ android_localisation/updates.py
10
11
  android_localisation/verify.py
11
12
  android_localisation.egg-info/PKG-INFO
12
13
  android_localisation.egg-info/SOURCES.txt
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "android-localisation"
7
- version = "1.1.1"
7
+ version = "1.1.2"
8
8
  description = "Zero-dependency Android strings.xml translation and verification using LLMs (Gemini, OpenAI, Anthropic, Ollama)."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }