Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
condense_vars,
declare_static,
declare_var,
derive,
decode_vars,
extract_vars,
index_vars,
Expand Down Expand Up @@ -106,11 +107,12 @@
"is_superset_locale",
"requires_translation",
"get_plural_form",
# Static
# Derive / variable helpers
"VAR_IDENTIFIER",
"VAR_NAME_IDENTIFIER",
"sanitize_var",
"declare_var",
"derive",
"declare_static",
"decode_vars",
"extract_vars",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from generaltranslation.static._condense_vars import condense_vars
from generaltranslation.static._constants import VAR_IDENTIFIER, VAR_NAME_IDENTIFIER
from generaltranslation.static._declare_static import declare_static
from generaltranslation.static._derive import declare_static, derive
from generaltranslation.static._declare_var import declare_var
from generaltranslation.static._decode_vars import decode_vars
from generaltranslation.static._extract_vars import extract_vars
Expand All @@ -12,6 +12,7 @@
"VAR_NAME_IDENTIFIER",
"sanitize_var",
"declare_var",
"derive",
"declare_static",
"decode_vars",
"extract_vars",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import annotations

import warnings


def derive(content: object) -> object:
"""Mark *content* as derivable (statically analyzable).

This is an identity function used as a marker for the CLI tool's
static analysis.
"""
return content


def declare_static(content: object) -> object:
"""Mark *content* as derivable (statically analyzable).
Comment thread
eoinest marked this conversation as resolved.

.. deprecated::
Use :func:`derive` instead.
Comment thread
eoinest marked this conversation as resolved.
"""
warnings.warn(
"declare_static() is deprecated, use derive() instead.",
DeprecationWarning,
stacklevel=2,
)
return derive(content)
3 changes: 2 additions & 1 deletion packages/gt-fastapi/src/gt_fastapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""FastAPI integration for General Translation."""

from gt_i18n import declare_static, declare_var, decode_vars, get_default_locale, get_locale, get_locales, t
from gt_i18n import declare_static, declare_var, decode_vars, derive, get_default_locale, get_locale, get_locales, t

from gt_fastapi._setup import initialize_gt

__all__ = [
"initialize_gt",
"t",
"declare_var",
"derive",
"declare_static",
"decode_vars",
"get_locale",
Expand Down
3 changes: 2 additions & 1 deletion packages/gt-flask/src/gt_flask/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Flask integration for General Translation."""

from gt_i18n import declare_static, declare_var, decode_vars, get_default_locale, get_locale, get_locales, t
from gt_i18n import declare_static, declare_var, decode_vars, derive, get_default_locale, get_locale, get_locales, t

from gt_flask._setup import initialize_gt

__all__ = [
"initialize_gt",
"t",
"declare_var",
"derive",
"declare_static",
"decode_vars",
"get_locale",
Expand Down
5 changes: 3 additions & 2 deletions packages/gt-i18n/src/gt_i18n/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Python i18n library for General Translation."""

from generaltranslation.static import declare_static, declare_var, decode_vars
from generaltranslation.static import declare_static, declare_var, decode_vars, derive

from gt_i18n.helpers._locales import (
get_default_locale,
Expand Down Expand Up @@ -49,8 +49,9 @@
"get_locale",
"get_locales",
"get_default_locale",
# Static variable helpers
# Derive / variable helpers
"declare_var",
"derive",
"declare_static",
"decode_vars",
]
Loading