Commit graph

244 commits

Author SHA1 Message Date
Anand Baburajan
38960f4219
feat: migrate translations command (#21362)
* feat: migrate translations command

* chore: formatting
2023-06-19 18:19:07 +05:30
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Ankush Menat
0b8b829483 perf: dont cache intermediate translation files
Just caching final files for each language is enough, duplicating
doesn't help much.
2023-04-11 12:10:49 +05:30
Ankush Menat
361e44de1d fix(translations)!: load translation in installed order
- translations are loaded in apps.txt order this doesnt make much sense.
- translations are loaded from apps which aren't even installed, again
  doesn't make sense.

Breaking but necessary change.
2023-04-11 12:10:45 +05:30
Gavin D'souza
d357af1533 refactor: Add a maxsplit limit to string splits 2023-01-24 19:22:51 +05:30
Ankush Menat
1b1e4de35e
chore!: dead code (#19551)
This was added for some very old patch code.

[skip ci]
2023-01-10 18:53:08 +05:30
Ankush Menat
e00023deb1 refactor: replace bad usage of db.set_value 2023-01-04 11:13:53 +05:30
Gavin D'souza
d3250f6504 refactor(whitelisted): Add typing hints to APIs
* Refactor type checks defined in APIs
* Remove dead/deprecated kwargs usages
* Added appropriate hints to APIs and consecutive utils defined in the following modules:
 - frappe.realtime
 - frappe.translate
 - frappe.utils.global_search
 - frappe.www.third_party_apps
 - frappe.www.search
 - frappe.www.printview
2022-12-15 13:47:05 +05:30
barredterra
67ede5d533 feat: add parameters language and letter_head to download_pdf 2022-12-14 13:59:46 +01:00
Ankush Menat
a1a296ac75
fix: ignore global translations (#18733)
_("string") outside of function/methods don't make any sense cause they
are initialized the moment module is imported. This is already checked
in CI yet people make this mistake.

Ignore and refuse to translate in those cases.
2022-11-03 03:00:03 +05:30
Ankush Menat
3ddac5fe92
refactor: accurate translation caching (#18595)
* refactor: rename poorly named functions

* refactor: getting translation from apps

- use generator
- use sane name for cache key
- avoid manual handling of frappe.local state just use cache() interface
2022-10-27 16:28:02 +05:30
Himanshu
192aa7a9ab
chore: linter fixes 2022-08-09 11:53:21 +01:00
Himanshu
44c2a2e309
Merge branch 'develop' into merge_translated_doctypes 2022-08-09 11:50:32 +01:00
mergify[bot]
cde6755aff
feat: Multilanguage sites: language selector only will show "enabled" languages and language default always will be System default (#17745) (#17766)
* feat: Select only enabled languages for "language selector", and use System Settings lang as default one

[skip ci]

(cherry picked from commit e5b8a47835d22b7834865324d30d796bb3031dd5)

Co-authored-by: Development for People <47140294+developmentforpeople@users.noreply.github.com>
2022-08-09 14:57:48 +05:30
Himanshu
b6281ffef6
chore: linter fixes 2022-08-09 09:49:21 +01:00
hrwx
b01929405d refactor: translatable doctypes 2022-08-05 21:38:10 +01:00
Ankush Menat
7452ac5d37
chore: correct default arg for extract_javascript
Tuples need extra comma to make sure it's not treated as string. 

[skip ci]

Co-authored-by: Sagar Vora <sagar@resilient.tech>
2022-08-04 15:52:32 +05:30
Ankush Menat
ec8f20c097 fix: send all messages on boot instead of scanning
close https://github.com/frappe/frappe/issues/17684
2022-08-04 15:33:03 +05:30
Ankush Menat
2d7fc1825f refactor: simplify get_messages_from_file 2022-08-04 15:33:03 +05:30
Ankush Menat
da872a0edf feat: modified parser for frappe JS translate syntax 2022-08-04 15:33:02 +05:30
Ankush Menat
cd53466b6a feat: JS extractor and custom JS parser 2022-08-04 15:19:56 +05:30
Ankush Menat
1425842ef0 refactor: extract python translations using babel
RIP my cool handwritten AST code :'(

Few things to note:

1. Publicly documented APIs, they don't support capturing kwargs.
2. We can't use documented "lower level" APIs, we need to go _even lower_.
2022-08-04 15:19:55 +05:30
Ankush Menat
ea836a824a feat: use AST to extract translation sources 2022-08-04 15:19:55 +05:30
Ankush Menat
0cb4da1195 fix: ignore built assets in translation 2022-08-04 15:19:55 +05:30
Ankush Menat
a1eaefefda refactor: simplfiy translate pattern
\s already includes \n
2022-08-04 14:50:24 +05:30
Ankush Menat
9a5d11234c
fix: validate scheduler, hook method names (#17400)
* chore: warn about missing scheduler / doc events

* fix: pass list instead of filter

filter can only be iterated upon once

* refactor: many typehints in __init__.py
2022-07-04 19:29:16 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Gavin D'souza
5f0555d982 fix: Translate strings in public folders too 2022-06-29 11:58:53 +05:30
Danny
47483f833f
feat(translations-cli): Fetch translations for a particular app (#17276)
* translataions for particular app 

get-untranslated/update-translations string for particular app frappe#17268 (feature request)

* fix: linting, making stuff DRY-er

Co-authored-by: gavin <gavin18d@gmail.com>
2022-06-24 17:04:49 +05:30
Gavin D'souza
b696fa6da5 perf: Pre-compile and re-use regexp pattern
Converted all possible usages of re.* that weren't compiling the regex
separately and re-using it. Separated out the compiled patterns as
global variables. Repetitive patterns could be made DRY-er.

Would be nicer to have all regexes in a single module so that we could
re-use better, keep track of outdated, and keep checks for possible
reDos' etc
2022-06-08 14:07:38 +05:30
Sagar Vora
97df77f954
perf(translation): improve if condition to return all values except None (#16953) 2022-05-23 12:58:42 +05:30
Ankush Menat
d90d6536ef perf: dont rebuild same translation dict 2022-05-22 22:54:23 +05:30
Ankush Menat
26b54221ea test: verify ALL translation file syntax 2022-05-13 16:12:40 +05:30
Ankush Menat
55def8b718 fix: recursion error in translations
If bad translations is found then while `msgprint` it attempts to load
translation again because of its arg `title = _("Message")`
2022-05-13 16:12:40 +05:30
Ankush Menat
b714dbb190
fix: dont throw error for a bad translation (#16769) 2022-04-27 10:49:56 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Ankush Menat
29ca4d7aaa feat: allow splitting _() function call on multiple lines 2022-03-26 16:18:35 +05:30
Ankush Menat
cf69b7f084 fix: only match 1 python context string at most 2022-03-26 16:18:35 +05:30
Ankush Menat
6fc3c30dc1 refactor: make translate regex readable 2022-03-26 16:18:33 +05:30
barredterra
8a4f316ec5 refactor: remove useless pass, log error 2022-03-20 02:35:35 +01:00
Suraj Shetty
4c2f14f824
Merge pull request #16079 from surajshetty3416/fix-translation-for-included-files 2022-02-22 19:05:01 +05:30
Suraj Shetty
eaf8327e0d fix: Use correct path of built assets
- Get path from bundled_assets
2022-02-22 18:43:16 +05:30
barredterra
745297a49d refactor: a not in b
Search: if not ([\w\d]*?) in ([\w\d]*?)
Replace: if $1 not in $2
2022-02-21 19:54:34 +01:00
barredterra
b1383df15a refactor: use is None instead of == None 2022-01-17 10:37:51 +01:00
Aradhya
9ccf467acb fix: fixed no order arg in converted queries 2021-11-23 13:30:42 +05:30
Aradhya
ed7b3f54a7 refactor: converted more queries 2021-11-20 15:02:22 +05:30
Aradhya
fcd480b2a8 refactor: Converted queries in translate 2021-11-18 09:56:41 +05:30
Aradhya-Tripathi
92ad93c9d7 fix: sider issues 2021-10-26 18:41:27 +05:30
Aradhya-Tripathi
56dfae64f3 fix: converted dependent queries 2021-10-26 18:32:50 +05:30
Aradhya-Tripathi
a76f64bbaf fix: fixing query in translate.py 2021-10-26 17:51:37 +05:30