Skip to content

Commit

Permalink
feat: update Russian translations and country info
Browse files Browse the repository at this point in the history
- Updated Russian translations in ru.po
- Corrected Russia country name in country_info.json
- Other minor fixes

parent 62e6410
author Metal Monkey <[email protected]> 1731764032 +0400
committer Metal Monkey <[email protected]> 1733503239 +0400

parent 62e6410
author Metal Monkey <[email protected]> 1731764032 +0400
committer Metal Monkey <[email protected]> 1733503170 +0400

	modified:   frappe/locale/ru.po

Fixed Russian geo data
	modified:   frappe/geo/country_info.json
	modified:   frappe/geo/languages.json

feat: Implement OAuth Backend App Flow for Email Accounts (frappe#27167)

* feat: Implement OAuth Backend App Flow for Email Accounts

* chore: Reformat to satisfy linter

* chore: format

Signed-off-by: Akhil Narang <[email protected]>

---------

Signed-off-by: Akhil Narang <[email protected]>
Co-authored-by: Akhil Narang <[email protected]>
(cherry picked from commit dde466b)

chore: resolve conflicts

Signed-off-by: Akhil Narang <[email protected]>

fix(change_log): skip checking if `develop` is part of the detected version

Signed-off-by: Akhil Narang <[email protected]>
(cherry picked from commit d7b74e9)

fix: get PDF from printview

Clicking "Get PDF" in printview should result in the same view being converted to PDF. So far, we didn't pass the print format and letterhead, sometimes resulting in an entirely different PDF.

(cherry picked from commit 834c31a)

fix: print_format can be None

Co-authored-by: Akhil Narang <[email protected]>
(cherry picked from commit 3f63583)

fix: improve permission error message (frappe#28292)

(cherry picked from commit 69a8a36)

chore: resolve conflicts

fix(query_report): Fall back to session user before validating permissions

(cherry picked from commit 572391a)

fix(query_report): Validate filters using `select` permission, not `read`

(cherry picked from commit 8cac65b)

chore: Format

(cherry picked from commit b410d7f)

fix: format value in custom dashboard chart

(cherry picked from commit 746c8d9)

fix: format tooltip value in custom dashboard chart

(cherry picked from commit e31c6db)

fix: parent translation tests (backport frappe#27852) (frappe#27853)

* fix: parent translation tests

(cherry picked from commit 9c90272)

* fix: Implement parent-child language precedence in get_all_translations

(cherry picked from commit 8e80ae7)

---------

Co-authored-by: David <[email protected]>

fix: add url to local for custom method to use (frappe#28493)

(cherry picked from commit 3a64eff)

Co-authored-by: David <[email protected]>

fix: add `summary` html element to `acceptable_elements`

(cherry picked from commit 066f7c6)

refactor: server script autocompletion to be more generic (frappe#28180) (frappe#28298)

(cherry picked from commit 8b1180b)

chore: split custom types into types module (frappe#28204) (frappe#28296)

(cherry picked from commit f7a7cef)

Co-authored-by: David Arnold <[email protected]>

refactor(user_query): switch to `frappe.get_list()`

(cherry picked from commit b3acb78)
Signed-off-by: Akhil Narang <[email protected]>

chore(release): Bumped to Version 15.48.0

* add `summary` html element to `acceptable_elements` ([dcdf3d4](frappe@dcdf3d4))
* add url to local for custom method to use ([frappe#28493](frappe#28493)) ([b8298ab](frappe@b8298ab))
* **change_log:** skip checking if `develop` is part of the detected version ([dfd0224](frappe@dfd0224))
* format tooltip value in custom dashboard chart ([c11745d](frappe@c11745d))
* format value in custom dashboard chart ([8b0c10e](frappe@8b0c10e))
* get PDF from printview ([95c85ec](frappe@95c85ec))
* improve permission error message ([frappe#28292](frappe#28292)) ([a53ba27](frappe@a53ba27))
* parent translation tests (backport [frappe#27852](frappe#27852)) ([frappe#27853](frappe#27853)) ([ffed945](frappe@ffed945))
* print_format can be None ([dcf2062](frappe@dcf2062))
* **query_report:** Fall back to session user before validating permissions ([a083468](frappe@a083468))
* **query_report:** Validate filters using `select` permission, not `read` ([adeba08](frappe@adeba08))

* Implement OAuth Backend App Flow for Email Accounts ([frappe#27167](frappe#27167)) ([80e92b4](frappe@80e92b4))

fix: ru translation of Designation

Responce for is_fc_site
ToDo: get value from site-config.json

Responce for is_fc_site
ToDo: get value from site-config.json

fix: total_fields not showing real value

chore: format js

fix: default length to available fields when undefined

fix: sync translations from crowdin (frappe#28440)

Co-authored-by: barredterra <[email protected]>

refactor: readability of translation tests (backport frappe#28519) (frappe#28520)

Co-authored-by: Raffael Meyer <[email protected]>

fix: user_query

(cherry picked from commit b250d19)

refactor(user_query): simplify with `as_list=True`

Signed-off-by: Akhil Narang <[email protected]>
(cherry picked from commit 1a8d9d1)

refactor(user_query): adjust query, only check fields if required

Signed-off-by: Akhil Narang <[email protected]>
(cherry picked from commit a350b5c)

fix: usability of Phone field (frappe#27076)

(cherry picked from commit 8332341)

fix: Disable link field triggers
- while opening doc from quick entry  to avoid revalidation

Co-authored-by: Akhil Narang <[email protected]>
(cherry picked from commit e7639a4)

fix(DocRename): on rename ignore link validation when updating values in single doctype

(cherry picked from commit 87ef74b)

fix(attach): don't crash when a web form field is read-only

`this.$input` and `this.$value` are undefined in those cases

Signed-off-by: Akhil Narang <[email protected]>
(cherry picked from commit 0d0951e)

fix(query_report): Check both read and select perms

(cherry picked from commit e1bfc1b)

refactor: change filter from tuple to dict

While list/dict both work and technically so does a tuple,
the original intention in frappe#13831 seems to have been a dict.
A trailing comma got left behind, which changed it to a tuple.

Signed-off-by: Akhil Narang <[email protected]>
(cherry picked from commit a7aa0de)

chore(release): Bumped to Version 15.48.1

* added api to send verification code and verify and login to fc ([e76cdf5](frappe@e76cdf5))
* added FC login modal with verification code feature ([77bb1ef](frappe@77bb1ef))
* **attach:** don't crash when a web form field is read-only ([b9ee9d7](frappe@b9ee9d7))
* changed support url ([e539a54](frappe@e539a54))
* default length to available fields when undefined ([20c087a](frappe@20c087a))
* Disable link field triggers ([c346aab](frappe@c346aab))
* **DocRename:** on rename ignore link validation when updating values in single doctype ([7e8e294](frappe@7e8e294))
* **query_report:** Check both read and select perms ([152d727](frappe@152d727))
* replaced header h4 with breadcrumbs component ([c117134](frappe@c117134))
* show trial plan based on is_trial_plan ([1657264](frappe@1657264))
* sync translations from crowdin ([frappe#28440](frappe#28440)) ([c480707](frappe@c480707))
* total_fields not showing real value ([93b3df0](frappe@93b3df0))
* usability of Phone field ([frappe#27076](frappe#27076)) ([6fc62fc](frappe@6fc62fc))
* user_query ([7d1a972](frappe@7d1a972))

feat: add clear all button to multiselect field

(cherry picked from commit 810519d)

feat: Disable allow renaming country (frappe#28596)

(cherry picked from commit c6c3d0a)

fix: enable fetching datetime fields from linked doctypes (frappe#28602)

(cherry picked from commit 0dcc628)

fix(rename): check for permissions for merged document as well

Signed-off-by: Akhil Narang <[email protected]>
(cherry picked from commit a70973b)

fix: sync translations from crowdin (frappe#28531)

* fix: Persian translations

* fix: Persian translations

* fix: Chinese Simplified translations

* fix: Swedish translations

* fix: Persian translations

* fix: Persian translations

* fix: Swedish translations

* fix: Persian translations

* fix: Arabic translations

* fix: Turkish translations

* fix: Persian translations

* fix: Spanish translations

* fix: Turkish translations

* fix: Swedish translations

* fix: Turkish translations

* fix: Turkish translations

feat: validate amended from record docstatus

(cherry picked from commit 35d8ff4)

feat(report_view): add some basic support for `read_only_depends_on`

Doesn't work that well

Signed-off-by: Akhil Narang <[email protected]>
(cherry picked from commit f266923)

chore(ui-tests): don't print subprocess traceback (backport frappe#28626) (frappe#28628)

* chore(ui-tests): don't print subprocess traceback

We have the cypress error from its output above, just a simple error message is enough here

Signed-off-by: Akhil Narang <[email protected]>
(cherry picked from commit 318a472)

* chore(ui-tests): raise click Exit exception

(cherry picked from commit aec58a9)

* chore: resolve conflicts

Signed-off-by: Akhil Narang <[email protected]>

---------

Signed-off-by: Akhil Narang <[email protected]>
Co-authored-by: Akhil Narang <[email protected]>
Co-authored-by: David <[email protected]>

fix: added api to get translation messages for portal apps

(cherry picked from commit dfe427b)

fix: workflow should also support queue_in_background

chore(release): Bumped to Version 15.49.0

* added api to get translation messages for portal apps ([0353afb](frappe@0353afb))
* enable fetching datetime fields from linked doctypes ([frappe#28602](frappe#28602)) ([9563c8a](frappe@9563c8a))
* **rename:** check for permissions for merged document as well ([d9a8722](frappe@d9a8722))
* sync translations from crowdin ([frappe#28531](frappe#28531)) ([0bd6a67](frappe@0bd6a67))
* workflow should also support queue_in_background ([3d51e72](frappe@3d51e72))

* add clear all button to multiselect field ([d1bf29d](frappe@d1bf29d))
* Disable allow renaming country ([frappe#28596](frappe#28596)) ([082aa60](frappe@082aa60))
* **report_view:** add some basic support for `read_only_depends_on` ([2991adf](frappe@2991adf))
* validate amended from record docstatus ([435dcb9](frappe@435dcb9))

fix: Print exception if asset linking is failed

(cherry picked from commit 225cc5b)
(cherry picked from commit c2628e1)

chore(release): Bumped to Version 15.49.1

* Print exception if asset linking is failed ([4c642bf](frappe@4c642bf))
  • Loading branch information
metalmon committed Dec 6, 2024
1 parent 62e6410 commit d0b78ca
Show file tree
Hide file tree
Showing 45 changed files with 7,846 additions and 7,229 deletions.
122 changes: 33 additions & 89 deletions frappe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

# Local application imports
from .exceptions import *
from .types.frappedict import _dict
from .utils.jinja import (
get_email_from_template,
get_jenv,
Expand All @@ -50,9 +51,38 @@
)
from .utils.lazy_loader import lazy_import

__version__ = "15.47.2"
__version__ = "15.49.1"
__title__ = "Frappe Framework"

# This if block is never executed when running the code. It is only used for
# telling static code analyzer where to find dynamically defined attributes.
if TYPE_CHECKING: # pragma: no cover
from werkzeug.wrappers import Request

from frappe.database.mariadb.database import MariaDBDatabase
from frappe.database.postgres.database import PostgresDatabase
from frappe.email.doctype.email_queue.email_queue import EmailQueue
from frappe.model.document import Document
from frappe.query_builder.builder import MariaDB, Postgres
from frappe.utils.redis_wrapper import RedisWrapper

db: MariaDBDatabase | PostgresDatabase
qb: MariaDB | Postgres
cache: RedisWrapper
response: _dict
conf: _dict
form_dict: _dict
flags: _dict
request: Request
session: _dict
user: str
flags: _dict
lang: str


# end: static analysis hack


controllers = {}
local = Local()
cache = None
Expand All @@ -67,28 +97,6 @@
warnings.simplefilter("always", PendingDeprecationWarning)


class _dict(dict):
"""dict like object that exposes keys as attributes"""

__slots__ = ()
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
__setstate__ = dict.update

def __getstate__(self):
return self

def update(self, *args, **kwargs):
"""update and return self -- the missing dict feature in python"""

super().update(*args, **kwargs)
return self

def copy(self):
return _dict(self)


def _(msg: str, lang: str | None = None, context: str | None = None) -> str:
"""Return translated string in current lang, if exists.
Usage:
Expand Down Expand Up @@ -137,45 +145,9 @@ def _lt(msg: str, lang: str | None = None, context: str | None = None):
Note: Result is not guaranteed to equivalent to pure strings for all operations.
"""
return _LazyTranslate(msg, lang, context)

from .types.lazytranslatedstring import _LazyTranslate

@functools.total_ordering
class _LazyTranslate:
__slots__ = ("msg", "lang", "context")

def __init__(self, msg: str, lang: str | None = None, context: str | None = None) -> None:
self.msg = msg
self.lang = lang
self.context = context

@property
def value(self) -> str:
return _(str(self.msg), self.lang, self.context)

def __str__(self):
return self.value

def __add__(self, other):
if isinstance(other, str | _LazyTranslate):
return self.value + str(other)
raise NotImplementedError

def __radd__(self, other):
if isinstance(other, str | _LazyTranslate):
return str(other) + self.value
return NotImplementedError

def __repr__(self) -> str:
return f"'{self.value}'"

# NOTE: it's required to override these methods and raise error as default behaviour will
# return `False` in all cases.
def __eq__(self, other):
raise NotImplementedError

def __lt__(self, other):
raise NotImplementedError
return _LazyTranslate(msg, lang, context)


def as_unicode(text, encoding: str = "utf-8") -> str:
Expand Down Expand Up @@ -216,34 +188,6 @@ def set_user_lang(user: str, user_language: str | None = None) -> None:

lang = local("lang")

# This if block is never executed when running the code. It is only used for
# telling static code analyzer where to find dynamically defined attributes.
if TYPE_CHECKING: # pragma: no cover
from werkzeug.wrappers import Request

from frappe.database.mariadb.database import MariaDBDatabase
from frappe.database.postgres.database import PostgresDatabase
from frappe.email.doctype.email_queue.email_queue import EmailQueue
from frappe.model.document import Document
from frappe.query_builder.builder import MariaDB, Postgres
from frappe.utils.redis_wrapper import RedisWrapper

db: MariaDBDatabase | PostgresDatabase
qb: MariaDB | Postgres
cache: RedisWrapper
response: _dict
conf: _dict
form_dict: _dict
flags: _dict
request: Request
session: _dict
user: str
flags: _dict
lang: str


# end: static analysis hack


def init(site: str, sites_path: str = ".", new_site: bool = False, force=False) -> None:
"""Initialize frappe for the current site. Reset thread locals `frappe.local`"""
Expand Down
5 changes: 3 additions & 2 deletions frappe/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ def make_asset_dirs(hard_link=False):
try:
print(start_message, end="\r")
link_assets_dir(source, target, hard_link=hard_link)
except Exception:
print(fail_message, end="\r")
except Exception as e:
print(e)
print(fail_message)

click.echo(unstrip(click.style("✔", fg="green") + " Application Assets Linked") + "\n")

Expand Down
6 changes: 5 additions & 1 deletion frappe/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,11 @@ def run_ui_tests(
formatted_command += " " + " ".join(cypressargs)

click.secho("Running Cypress...", fg="yellow")
frappe.commands.popen(formatted_command, cwd=app_base_path, raise_err=True)
try:
frappe.commands.popen(formatted_command, cwd=app_base_path, raise_err=True)
except subprocess.CalledProcessError as e:
click.secho("Cypress tests failed", fg="red")
raise click.exceptions.Exit(1) from e


@click.command("serve")
Expand Down
48 changes: 11 additions & 37 deletions frappe/core/doctype/server_script/server_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# License: MIT. See LICENSE

from functools import partial
from types import FunctionType, MethodType, ModuleType
from itertools import chain

import frappe
from frappe import _
from frappe.model.document import Document
from frappe.rate_limiter import rate_limit
from frappe.utils.safe_exec import (
FrappeTransformer,
NamespaceDict,
get_keys_for_autocomplete,
get_safe_globals,
is_safe_exec_enabled,
safe_exec,
Expand Down Expand Up @@ -208,41 +208,15 @@ def get_autocompletion_items(self):
For e.g., ["frappe.utils.cint", "frappe.get_all", ...]
"""

def get_keys(obj):
out = []
for key in obj:
if key.startswith("_"):
continue
value = obj[key]
if isinstance(value, NamespaceDict | dict) and value:
if key == "form_dict":
out.append(["form_dict", 7])
continue
for subkey, score in get_keys(value):
fullkey = f"{key}.{subkey}"
out.append([fullkey, score])
else:
if isinstance(value, type) and issubclass(value, Exception):
score = 0
elif isinstance(value, ModuleType):
score = 10
elif isinstance(value, FunctionType | MethodType):
score = 9
elif isinstance(value, type):
score = 8
elif isinstance(value, dict):
score = 7
else:
score = 6
out.append([key, score])
return out

items = frappe.cache.get_value("server_script_autocompletion_items")
if not items:
items = get_keys(get_safe_globals())
items = [{"value": d[0], "score": d[1]} for d in items]
frappe.cache.set_value("server_script_autocompletion_items", items)
return items
return frappe.cache.get_value(
"server_script_autocompletion_items",
generator=lambda: list(
chain.from_iterable(
get_keys_for_autocomplete(key, value, meta="utils")
for key, value in get_safe_globals().items()
),
),
)


def setup_scheduler_events(script_name: str, frequency: str, cron_format: str | None = None):
Expand Down
59 changes: 33 additions & 26 deletions frappe/core/doctype/translation/test_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,44 @@ def tearDown(self):

def test_doctype(self):
translation_data = get_translation_data()
for key, val in translation_data.items():
frappe.local.lang = key
for lang, (source_string, new_translation) in translation_data.items():
frappe.local.lang = lang
original_translation = _(source_string)

translation = create_translation(key, val)
self.assertEqual(_(val[0]), val[1])
docname = create_translation(lang, source_string, new_translation)
self.assertEqual(_(source_string), new_translation)

frappe.delete_doc("Translation", translation.name)
self.assertEqual(_(val[0]), val[0])
frappe.delete_doc("Translation", docname)
self.assertEqual(_(source_string), original_translation)

def test_parent_language(self):
data = [
["es", ["Test Data", "datos de prueba"]],
["es", ["Test Spanish", "prueba de español"]],
["es-MX", ["Test Data", "pruebas de datos"]],
]

for key, val in data:
create_translation(key, val)
data = {
"Test Data": {
"es": "datos de prueba",
"es-MX": "pruebas de datos",
},
"Test Spanish": {
"es": "prueba de español",
},
}

for source_string, translations in data.items():
for lang, translation in translations.items():
create_translation(lang, source_string, translation)

frappe.local.lang = "es"

self.assertTrue(_(data[0][0]), data[0][1])
self.assertEqual(_("Test Data"), data["Test Data"]["es"])

self.assertTrue(_(data[1][0]), data[1][1])
self.assertEqual(_("Test Spanish"), data["Test Spanish"]["es"])

frappe.local.lang = "es-MX"

# different translation for es-MX
self.assertTrue(_(data[2][0]), data[2][1])
self.assertEqual(_("Test Data"), data["Test Data"]["es-MX"])

# from spanish (general)
self.assertTrue(_(data[1][0]), data[1][1])
self.assertEqual(_("Test Spanish"), data["Test Spanish"]["es"])

def test_multi_language_translations(self):
source = "User"
Expand All @@ -72,7 +78,7 @@ def test_html_content_data_translation(self):
los procesadores Intel Core i5 e i7 de quinta generación con Intel HD Graphics 6000 son capaces de hacerlo.
"""

create_translation("es", [source, target])
create_translation("es", source, target)

source = """
<span style="font-family: &quot;Amazon Ember&quot;, Arial, sans-serif; font-size:
Expand Down Expand Up @@ -102,10 +108,11 @@ def get_translation_data():
}


def create_translation(key, val):
translation = frappe.new_doc("Translation")
translation.language = key
translation.source_text = val[0]
translation.translated_text = val[1]
translation.save()
return translation
def create_translation(lang, source_string, new_translation) -> str:
doc = frappe.new_doc("Translation")
doc.language = lang
doc.source_text = source_string
doc.translated_text = new_translation
doc.save()

return doc.name
Loading

0 comments on commit d0b78ca

Please sign in to comment.