[openstreetmap/openstreetmap-website] Help for translators with interpolation (Issue #3939)
Andy Allan
notifications at github.com
Thu Feb 23 10:50:06 UTC 2023
In a [commit comment](https://github.com/openstreetmap/openstreetmap-website/commit/c7e9888bb6587649109d0c8d9e00c771da867cf9#commitcomment-101769123), @Nikerabbit writes:
> These changes are really difficult for translators because they are create patchwork messages. Especially without accompanying message documentation.
>
> More docs:
>
> https://translatewiki.net/wiki/Translating:Localisation_for_developers#Message_documentation
> https://www.mediawiki.org/wiki/Help:System_message#Avoid_fragmented_or_'patchwork'_messages
>
> To be fair, we have the same issue in MediaWiki. Often it can be addressed by using wikitext, but some cases that is not possible. Best would be inline syntax that handles context-dependent escaping. For example:
>
> messages:
> signup_message: Please ${elem|sign up}
>
> code using fake PHP syntax as I am not familiar with Ruby:
>
> t( 'signup_message', function ( $label ) { return makeButton( 'someurl', htmlspecialchars( $label ) ); } );
>
> But in the meantime, I hope message doc can be added cross-linking the translatable messages to each other.
I'm opening this issue to explore what we can do to make it easier for our translators to handle translations with interpolations. The most common usage of the interpolations are for links, where the link text is used by a link helper and then interpolated into the rest of the sentence, for example:
```yaml
en:
diary_entries:
show:
login_to_leave_a_comment_html: '%{login_link} to leave a comment'
login: Login
```
```ruby
t(".login_to_leave_a_comment_html", :login_link => link_to(t(".login"), login_path(:referer => request.fullpath)))
```
I'm currently working on a series of PRs to remove all the raw html from the translations, and so this interpolation approach is also being used for html within sentences (bold, emphasis etc) like:
```yaml
en:
site:
welcome:
whats_on_the_map:
off_the_map_html: |
What it %{doesnt} include is opinionated data like ratings, historical or
hypothetical features, and data from copyrighted sources. Unless you have special
permission, don't copy from online or paper maps.
doesnt: doesn't
```
```ruby
t ".whats_on_the_map.off_the_map_html", :doesnt => tag.em(t(".whats_on_the_map.doesnt"))
```
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/3939
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/issues/3939 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20230223/42ce64a1/attachment.htm>
More information about the rails-dev
mailing list