Closed
Bug 1013891
Opened 9 years ago
Closed 9 years ago
Move pref and message-manager strings to constants
Categories
(Firefox :: Translation, defect)
Firefox
Translation
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: mikedeboer, Assigned: mikedeboer)
References
Details
Attachments
(1 file)
10.61 KB,
patch
|
florian
:
review-
|
Details | Diff | Splinter Review |
In Translation.jsm I noticed that pref names and message identifiers are hardcoded and duplicated inside methods. Preferably, we'd move these strings to the top of each file to 1) improve readability 2) improve usability 3) prevent typos in the future.
Flags: firefox-backlog+
Assignee | ||
Comment 1•9 years ago
|
||
Marco, can you add this to the current iteration?
Assignee: nobody → mdeboer
Status: NEW → ASSIGNED
Flags: needinfo?(mmucci)
Whiteboard: p=2 [qa-]
Assignee | ||
Comment 2•9 years ago
|
||
Attachment #8426891 -
Flags: review?(florian)
Comment 3•9 years ago
|
||
Added to Iteration 32.2
Flags: needinfo?(mmucci)
Whiteboard: p=2 [qa-] → p=2 s=it-32c-31a-30b.2 [qa-]
Comment 4•9 years ago
|
||
Comment on attachment 8426891 [details] [diff] [review] Patch v1: move often used strings to shared constants Review of attachment 8426891 [details] [diff] [review]: ----------------------------------------------------------------- I think the cost of hiding the constant values in a separate file and of having to use the preprocessor outweighs the benefit of reducing the typo risk. I think I would prefer having the constants defined at the top of both file. That's a small duplication, but the risk of typo while copying whole lines seems almost non existent. ::: browser/components/translation/constants.js @@ +4,5 @@ > + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ > +#endif > + > +const TRANSLATION_SOURCE_LANGUAGES = ["en", "zh", "ja", "es", "de", "fr", "ru", "ar", "ko", "pt"]; > +const TRANSLATION_TARGET_LANGUAGES = ["en", "pl", "tr", "vi"]; These 2 arrays weren't duplicated, right?
Attachment #8426891 -
Flags: review?(florian) → review-
Assignee | ||
Updated•9 years ago
|
Assignee | ||
Comment 5•9 years ago
|
||
(In reply to Florian Quèze [:florian] [:flo] from comment #4) > I think the cost of hiding the constant values in a separate file and of > having to use the preprocessor outweighs the benefit of reducing the typo > risk. > > I think I would prefer having the constants defined at the top of both file. > That's a small duplication, but the risk of typo while copying whole lines > seems almost non existent. Sure, matter of taste, but sure. I'll post an updated patch later. NB: the reason I opted for this method is because I generally like to avoid having to browse through a list of constants before I get to the meat of a module. I consider it boilerplate and not volatile code (hence the term 'constant'). However, the cost of separating constants to their own respective module is too much work and, as we all know, module loading is not cheap. Hence the choice to include it using pre-processor directive, because that's free at run-time.
Comment 6•9 years ago
|
||
I actually don't like the indirection of using constants for this - the typo risk seems small (and should be covered by tests!), and it adds an extra step when grepping for where messages are sent/observed, which I find make understanding the code slightly harder.
Assignee | ||
Updated•9 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
Updated•9 years ago
|
Flags: firefox-backlog+ → firefox-backlog-
Whiteboard: p=2 s=it-32c-31a-30b.2 [qa-]
You need to log in
before you can comment on or make changes to this bug.
Description
•