Comments (5)
To answer the original request, the way I'd implement this is by defining a new setting, e.g. ROSETTA_LINK_OCCURRENCES
which should be a callable taking the occurrence string (e.g. "templates/test.html:3"
) and return an URL or None
. We could then call that callable for every entry in the form page and if the result is a link, we'd add a hyperlink on the occurrence.
Thoughts?
from django-rosetta.
If the reference content (see definition) is directly a valid URL (e.g. when I edit the PO file and add a #. https://foo.bar.com line to an item) that URL should be turned into a clickable link either.
#.
is used for extracted-comments, not for references, #:
is used for references.
Apart from that, if I'm not wrong you want to use URLs as references and convert URLs to a
DOM elements in Rosetta interface. This could be done tweaking a bit the Django makemessages extraction process with a custom management command:
import polib
from django.core.management.commands.makemessages import (
BuildFile as MakeMessagesBuildFile,
Command as MakeMessagesCommand
)
class MakeProperMessagesBuildFile(MakeMessagesBuildFile):
def postprocess_messages(self, msgs):
po = polib.POFile(super().postprocess_messages(msgs))
for entry in po:
# do whatever you want, in this case if "Url: <...>" found in msgctxt
# or URL found by regex, move it to `ocurrences`...
return str(po)
class Command(MakeMessagesCommand):
build_file_class = MakeProperMessagesBuildFile
And then, inherit from rosetta form.html
template and add a bit of Javascript. Something like:
from rosetta.views import TranslationFormView
TranslationFormView.template_name = "path/to/your/custom-template.html"
{% include 'rosetta/form.html' %}
{% include 'my-crazy-hack-for-rosetta-interface.html' %}
I think your proposal is interesting, but maybe not standard enough to be implemented in Django core.
from django-rosetta.
I think your proposal is interesting, but maybe not standard enough to be implemented in Django core.
I think the contrary. My proposal is about improving the general usability of Rosetta. Think: What is a link to a file location worth in 2021 when it's not effortless to reach it in the source code repository to, e.g., fix the related text string?
If you have to do copy+paste, or plain remember filename and line number, and go searching in your file system then the project will rather sooner than later be abandoned, because it doesn't meet the expectations of a continuously larger part of the (developer) audience.
Translation support tools must allow translators to focus on translating, and in a similar manner developers to focus on fixing spelling mistakes. Speed matters, distractions count.
This could be done tweaking a bit the Django makemessages extraction process
That's technically possible, I agree, but I guess the better place is the rendering process for the user interface.
from django-rosetta.
Could be interesting, but shouldn't be ROSETTA_OCCURRENCES
the name for this setting? You might want to modify the HTML code by adding other elements to the DOM beyond links.
from django-rosetta.
Sounds good to me. Is your suggestion just about the setting and the implementation of turning the text into a link, or do you think about a default implementation of the callable, too?
If we had, say, a ROSETTA_VCS_URL
and a ROSETTA_VCS_REVISION
we could have a default implementation that might work for simple, single-repository projects. This could be a helpful starting point, aka reference implementation, for custom setups.
from django-rosetta.
Related Issues (20)
- TemplateDoesNotExist at /rosetta/files/project HOT 2
- Why request some url `https://www.google.com/jsapi` HOT 2
- 'Last-Translator' is written as b'....' in pofile
- Plurals with context are rendered incorrectly HOT 6
- `re_path` is not available in django==4.0 anymore HOT 3
- request or news (I can look) save to database for docker HOT 5
- Why split `DJANGO_SETTINGS_MODULE` in function find_pos()? HOT 1
- Missing Azure Location setting HOT 1
- Export Django-rosetta translations HOT 1
- DeepL suggestions not working HOT 1
- Triple entries in local dev env on Mac HOT 8
- anyone can add chatgpt support? HOT 2
- DeepL translates variable names
- DeepL Pro support HOT 3
- Updating docs to get ROSETTA_LANGUAGE_GROUPS=True working HOT 1
- REFLANG not working anymore? HOT 1
- Infinite Redirected Loop when Accessing Django Rosetta Page with users other than superuser HOT 1
- Chinese locale directory should be named 'zh_Hans' instead of 'zh_hans' HOT 2
- How to translate third-party apps?
- TypeError at../rosetta/files/project HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-rosetta.