-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix: translation repository browser #19184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b92788a
7e54b1a
d0b8058
b077ac0
8b992c2
2f90a06
d45be02
2ae1b03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -457,6 +457,23 @@ might want to strip leading directory by ``parentdir`` filter (see | |||||
| :ref:`markup`): | ||||||
| ``https://github.com/WeblateOrg/hello/blob/{{branch}}/{{filename|parentdir}}#L{{line}}`` | ||||||
|
|
||||||
| .. seealso:: | ||||||
|
|
||||||
| * :setting:`PROJECT_WEB_RESTRICT_PRIVATE` | ||||||
|
|
||||||
| .. _component-repoweb-translations: | ||||||
|
|
||||||
| Repository browser for translations | ||||||
| +++++++++++++++++++++++++++++++++++++ | ||||||
|
|
||||||
| URL of repository browser used to display translation files. When empty, the | ||||||
| :ref:`component-repoweb` URL will be used as a fallback. This is useful when | ||||||
| the source files and translation files are hosted in different repositories. | ||||||
| You can use :ref:`markup`. | ||||||
|
|
||||||
| For example on GitHub, use something like: | ||||||
| ``https://github.com/WeblateOrg/translations/blob/{{branch}}/{{filename}}#L{{line}}`` | ||||||
|
||||||
| ``https://github.com/WeblateOrg/translations/blob/{{branch}}/{{filename}}#L{{line}}`` | |
| ``https://github.com/WeblateOrg/translations/blob/{{branch}}/{{filename}}#L{{line}}`` |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This migration is not based on the current main: Please rename it and adjust dependencies. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Copyright © Michal Čihař <michal@weblate.org> | ||
| # | ||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
| import weblate.utils.render | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("trans", "0073_alter_change_action"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="component", | ||
| name="repoweb_translations", | ||
| field=models.CharField( | ||
| blank=True, | ||
| help_text="Link to repository browser for translation files, use {{branch}} for branch, {{filename}} and {{line}} as filename and line placeholders. If left empty, the Repository browser above will be used. You might want to strip leading directory by using {{filename|parentdir}}.", | ||
| max_length=200, | ||
| validators=[weblate.utils.render.validate_repoweb], | ||
| verbose_name="Repository browser for translations", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -534,6 +534,18 @@ class Component( # noqa: PLR0904 | |
| validators=[validate_repoweb], | ||
| blank=True, | ||
| ) | ||
| repoweb_translations = models.CharField( | ||
| verbose_name=gettext_lazy("Repository browser for translations"), | ||
| max_length=200, | ||
| help_text=gettext_lazy( | ||
| "Link to repository browser for translation files, use {{branch}} for branch, " | ||
| "{{filename}} and {{line}} as filename and line placeholders. " | ||
| "If left empty, the Repository browser above will be used. " | ||
| "You might want to strip leading directory by using {{filename|parentdir}}." | ||
| ), | ||
| validators=[validate_repoweb], | ||
| blank=True, | ||
| ) | ||
| git_export = models.CharField( | ||
| verbose_name=gettext_lazy("Exported repository URL"), | ||
| max_length=60 + PROJECT_NAME_LENGTH + COMPONENT_NAME_LENGTH, | ||
|
|
@@ -1807,6 +1819,7 @@ def get_repoweb_link( | |
| line: str, | ||
| template: str | None = None, | ||
| user: User | None = None, | ||
| is_translation: bool = False, | ||
| ): | ||
| """ | ||
| Generate link to source code browser for given file and line. | ||
|
|
@@ -1815,7 +1828,9 @@ def get_repoweb_link( | |
| here. | ||
| """ | ||
|
Comment on lines
1824
to
1829
|
||
| if not template: | ||
| if self.repoweb: | ||
| if is_translation and self.repoweb_translations: | ||
| template = self.repoweb_translations | ||
| elif self.repoweb: | ||
| template = self.repoweb | ||
| elif user and user.has_perm("vcs.view", self): | ||
|
Comment on lines
1830
to
1835
|
||
| template = getattr( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will break rendering without newline:
Also, the
seealsoshould be present in both of thse.