Non-existence of strings in the source code


(Safa Alfulaij) #1

Hello!

There are some strings in Transifex that I couldn’t look up in the source code (to know the context).
For example (in server.en.yml):

  • “%{username} via %{site_name}” with key “via”
  • “is reserved” with key “is_reserved”
  • “%{attribute} %{message}” with key “errors.format”
  • Many strings with keys starting with “errors.messages”

I hope that I’m mistaken, but leaving many strings like that isn’t really good :smile:


(Jeff Atwood) #2

Sure can you have a look @techapj?


(Arpit Jalan) #3

I deleted the unused keys via and is_reserved.

The errors.* keys are used for Rails validation error messages, you may not be able to find them in source code but believe me they are there for a reason :smile: See this topic for more context:



How to find translation for validation message?
(Arpit Jalan) #4

(Arpit Jalan) #5

(Arpit Jalan) #6

Topic reopened as per request by @SafaAlfulaij

Changed the category from bug -> dev/translations


(Safa Alfulaij) #7

Great, thanks @techAPJ!
I would like to say that coping strings from a dependency is not a good idea. These strings might be changed or deleted anytime. It would be better to get rid of them and submitting a PR to Rails rather than copying the strings to Discourse :wink:


(Erick Guan) #8

The context of request looks like missing.

Would you like to amend something if applies?

Anyway, here is a relevant post about how to find those errors and translation guidance. Hope it helps.


(Safa Alfulaij) #9

HI!
Looks like we’ve found more unused strings!

  • js.posts_long
  • js.likes_long
  • js.views_long
  • js.post.more_links
  • js.topic.feature_topic.confirm_pin_globally
  • js.topic.feature_topic.confirm_pin
  • js.topic.feature_topic.unpin_until
  • js.topic.feature_topic.unpin_globally
  • js.topic.feature_topic.unpin_globally_until
  • js.topic.timeline.replies
  • js.topic.progress.position

And more! EDIT: 1

  • js.posts_lowercase
  • js.likes_long
  • js.post.actions.it_too. (All of them?)

I wonder if it’s possible to make a script that checks for unused strings…


(Jeff Atwood) #10

Sure @techapj can you confirm these strings are no longer in use, and if so, remove them?


(Arpit Jalan) #11

Used here:

Used here:

Used here:

Removed these keys:

  • js.post.more_links
  • js.topic.timeline.replies
  • js.topic.progress.position
  • js.posts_lowercase
  • js.post.actions.it_too (entire set)

(Safa Alfulaij) #12

Well, discourse/directory-toggle.js.es6 at be3a5a56ccc284b352aa65080fc6b955f73cc72a · discourse/discourse · GitHub is actually these: discourse/client.en.yml at be3a5a56ccc284b352aa65080fc6b955f73cc72a · discourse/discourse · GitHub

And for the others, it’s waay better to keep a whole string rather than appending to an existing string :slight_smile: I think that maintaining strings will be easier.
Puzzle strings are always a bad practice, in the translation text or the translation key.

And thanks! :slight_smile:

EDIT:
I’m not sure if a PR that changes these bad practices is considered as a good or bad one (According to that topic about code refactoring and what’s acceptable and whats not).