Skip to content
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

Properly localize numbers #2557

Merged
merged 3 commits into from
Sep 19, 2022

Conversation

ChunkyProgrammer
Copy link
Member

@ChunkyProgrammer ChunkyProgrammer commented Sep 9, 2022


Properly localize numbers

Pull Request Type
Please select what type of pull request this is:

  • Bugfix

Related issue
closes #2547

Description
Number seperators (",", "." and " ") were not chosen based on locale and were always shown as ","

Screenshots (if appropriate)
image

Testing (for code that is not small enough to be easily understandable)
Used search with different locales (had to clear search to test)

Desktop (please complete the following information):

  • OS: Windows
  • OS Version: 11
  • FreeTube version: 0.17.1

@PrestonN PrestonN enabled auto-merge (squash) September 9, 2022 19:22
@ChunkyProgrammer ChunkyProgrammer added the PR: waiting for review For PRs that are complete, tested, and ready for review label Sep 9, 2022
absidue
absidue previously approved these changes Sep 9, 2022
@efb4f5ff-1298-471a-8973-3d47447115dc

I saw this #853 issue from the same author. Is this harder to fix?

@ChunkyProgrammer
Copy link
Member Author

I saw this #853 issue from the same author. Is this harder to fix?

I haven't really looked into that issue

@Aiz0
Copy link
Contributor

Aiz0 commented Sep 9, 2022

While working on #2559 I noticed that 'en' will be used to format Like and Dislike numbers if no locale in freetube is set.
Should 'en' be replaced with 'default' so system locales format is used for this?

diff --git a/src/renderer/components/watch-video-info/watch-video-info.js b/src/renderer/components/watch-video-info/watch-video-info.js
index 4746dc55..6cc98007 100644
--- a/src/renderer/components/watch-video-info/watch-video-info.js
+++ b/src/renderer/components/watch-video-info/watch-video-info.js
@@ -219,7 +219,7 @@ export default Vue.extend({
       }
 
       const locale = this.currentLocale.replace('_', '-')
-      return this.likeCount.toLocaleString([locale, 'en'])
+      return this.likeCount.toLocaleString([locale, 'default'])
     },
 
     parsedDislikeCount: function () {
@@ -228,7 +228,7 @@ export default Vue.extend({
       }
 
       const locale = this.currentLocale.replace('_', '-')
-      return this.dislikeCount.toLocaleString([locale, 'en'])
+      return this.dislikeCount.toLocaleString([locale, 'default'])
     },
 
     likePercentageRatio: function () {

@ChunkyProgrammer
Copy link
Member Author

While working on #2559 I noticed that 'en' will be used to format Like and Dislike numbers if no locale in freetube is set. Should 'en' be replaced with 'default' so system locales format is used for this?

diff --git a/src/renderer/components/watch-video-info/watch-video-info.js b/src/renderer/components/watch-video-info/watch-video-info.js
index 4746dc55..6cc98007 100644
--- a/src/renderer/components/watch-video-info/watch-video-info.js
+++ b/src/renderer/components/watch-video-info/watch-video-info.js
@@ -219,7 +219,7 @@ export default Vue.extend({
       }
 
       const locale = this.currentLocale.replace('_', '-')
-      return this.likeCount.toLocaleString([locale, 'en'])
+      return this.likeCount.toLocaleString([locale, 'default'])
     },
 
     parsedDislikeCount: function () {
@@ -228,7 +228,7 @@ export default Vue.extend({
       }
 
       const locale = this.currentLocale.replace('_', '-')
-      return this.dislikeCount.toLocaleString([locale, 'en'])
+      return this.dislikeCount.toLocaleString([locale, 'default'])
     },
 
     likePercentageRatio: function () {

Sounds like a good idea to me, maybe keep 'en' but move it after default?

@absidue
Copy link
Member

absidue commented Sep 10, 2022

@ChunkyProgrammer You shouldn't need to specify default here as you are getting the locale properly through i18n, so there will always be a locale set, the other PR doesn't currently do that.

@efb4f5ff-1298-471a-8973-3d47447115dc

Screenshot (268)

Views says NaN?

Co-authored-by: Aiz <66974576+Aiz0@users.noreply.github.com>
@PrestonN PrestonN merged commit 8fa182e into FreeTubeApp:development Sep 19, 2022
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Sep 19, 2022
@ChunkyProgrammer ChunkyProgrammer deleted the localize-numbers branch April 12, 2023 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Localized separators
6 participants