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

Slow time with natural language #39

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ all: build
.PHONY: build
build: locale/clock-override.pot $(distfiles)

locale/clock-override.pot: prefs.js
locale/clock-override.pot: format.js prefs.js
xgettext --from-code=UTF-8 -k_ -kN_ -o $@ $?

%.mo: %.po
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For techies, we use the [`GLib GDateTime` codes](https://developer.gnome.org/gli

* `%;cf`, a little emoji Unicode clock face (thanks to [dsboger](https://github.com/stuartlangridge/gnome-shell-clock-override/commit/5941974a39d3dfa4f7adb227bdbe3bc50118bbc9) for that!)
* `%;vf`, quarters as vulgar fractions
* `%;nf`, quarters in natural language
* `%;@`, internet time (.beat)

Note that we still try to honour Gnome Shell's clock settings. So if you expect your clock to show seconds (or to update once a second, rather than once a minute) then you'll need to have turned on "show seconds" in Gnome Tweak Tool (under Top Bar) (or [the terminal way](https://askubuntu.com/questions/39412/how-to-show-seconds-on-the-clock-in-gnome-3)).
Expand Down
47 changes: 47 additions & 0 deletions format.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,53 @@ function format(FORMAT, now) {
var vulgar_fraction = ["\u2070/\u2080", "\u00B9/\u2084", "\u00B9/\u2082", "\u00B3/\u2084", "\u00B9/\u2081"][quarters];
desired = desired.replace(/%;vf/g, vulgar_fraction);
}
if (FORMAT.indexOf("%;nf") > -1) {
var quarters = Math.round(now.get_minute() / 15);

var hour = now.get_hour();

// convert from 0-23 to 1-12
if (hour > 12) {
hour -= 12;
}
if (hour == 0) {
hour = 12;
}

// convert from 0-23 to 1-12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code duplication, would be better to create a function that does the 0-23 to 1-12 conversion.

var next_hour = hour + 1;
if (next_hour > 12) {
next_hour -= 12;
}
if (next_hour == 0) {
next_hour = 12;
}

var natural_hours = [
_("one"),
_("two"),
_("three"),
_("four"),
_("five"),
_("six"),
_("seven"),
_("eight"),
_("nine"),
_("ten"),
_("eleven"),
_("twelve")
];
var natural_language = [
_("%;naturalI o'clock"),
_("quarter past %;naturalI"),
_("half past %;naturalI"),
_("quarter to %;nextNaturalI"),
_("%;nextNaturalI o'clock")
][quarters];
natural_language = natural_language.replace(/%;naturalI/, natural_hours[hour-1]);
natural_language = natural_language.replace(/%;nextNaturalI/, natural_hours[next_hour-1]);
desired = desired.replace(/%;nf/g, natural_language);
}
if (FORMAT.indexOf("%;cf") > -1) {
var hour = now.get_hour();
// convert from 0-23 to 1-12
Expand Down
82 changes: 77 additions & 5 deletions locale/clock-override.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-15 18:48+0200\n"
"POT-Creation-Date: 2019-02-17 13:13+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -17,6 +17,74 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: format.js:71
msgid "one"
msgstr ""

#: format.js:72
msgid "two"
msgstr ""

#: format.js:73
msgid "three"
msgstr ""

#: format.js:74
msgid "four"
msgstr ""

#: format.js:75
msgid "five"
msgstr ""

#: format.js:76
msgid "six"
msgstr ""

#: format.js:77
msgid "seven"
msgstr ""

#: format.js:78
msgid "eight"
msgstr ""

#: format.js:79
msgid "nine"
msgstr ""

#: format.js:80
msgid "ten"
msgstr ""

#: format.js:81
msgid "eleven"
msgstr ""

#: format.js:82
msgid "twelve"
msgstr ""

#: format.js:85
msgid "%;naturalI o'clock"
msgstr ""

#: format.js:86
msgid "quarter past %;naturalI"
msgstr ""

#: format.js:87
msgid "half past %;naturalI"
msgstr ""

#: format.js:88
msgid "quarter to %;nextNaturalI"
msgstr ""

#: format.js:89
msgid "%;nextNaturalI o'clock"
msgstr ""

#: prefs.js:51
msgid "Text to display instead of the clock"
msgstr ""
Expand Down Expand Up @@ -46,22 +114,26 @@ msgid "Slow time (quarters as fractions)"
msgstr ""

#: prefs.js:83
msgid "ISO date and time (2014-01-30T14:50:10)"
msgid "Slow time (quarters in natural language)"
msgstr ""

#: prefs.js:84
msgid "Local and Internet time"
msgid "ISO date and time (2014-01-30T14:50:10)"
msgstr ""

#: prefs.js:85
msgid "Local and Internet time"
msgstr ""

#: prefs.js:86
msgid "Something sillier"
msgstr ""

#: prefs.js:85
#: prefs.js:86
msgid "It is %M minutes past hour %H"
msgstr ""

#: prefs.js:120
#: prefs.js:121
#, javascript-format
msgid "What do all these %x codes mean?"
msgstr ""
81 changes: 76 additions & 5 deletions locale/de/LC_MESSAGES/clock-override.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: GNOME Shell Extension Clock Override\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-20 18:26+0200\n"
"POT-Creation-Date: 2019-02-17 13:13+0100\n"
"PO-Revision-Date: 2018-08-15 18:36+0200\n"
"Last-Translator: Jonatan Hatakeyama Zeidler <[email protected]>\n"
"Language-Team: Jonatan H. Zeidler, Matthäus Brandl\n"
Expand All @@ -19,6 +19,73 @@ msgstr ""
"X-Poedit-SourceCharset: UTF-8\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: format.js:71
msgid "one"
msgstr ""

#: format.js:72
msgid "two"
msgstr ""

#: format.js:73
msgid "three"
msgstr ""

#: format.js:74
msgid "four"
msgstr ""

#: format.js:75
msgid "five"
msgstr ""

#: format.js:76
msgid "six"
msgstr ""

#: format.js:77
msgid "seven"
msgstr ""

#: format.js:78
msgid "eight"
msgstr ""

#: format.js:79
msgid "nine"
msgstr ""

#: format.js:80
msgid "ten"
msgstr ""

#: format.js:81
msgid "eleven"
msgstr ""

#: format.js:82
msgid "twelve"
msgstr ""

#: format.js:85
msgid "%;naturalI o'clock"
msgstr ""

#: format.js:86
msgid "quarter past %;naturalI"
msgstr ""

#: format.js:87
msgid "half past %;naturalI"
msgstr ""

#: format.js:88
msgid "quarter to %;nextNaturalI"
msgstr ""

#: format.js:89
msgid "%;nextNaturalI o'clock"
msgstr ""

#: prefs.js:51
msgid "Text to display instead of the clock"
Expand Down Expand Up @@ -49,23 +116,27 @@ msgid "Slow time (quarters as fractions)"
msgstr "Slow-Zeit (Viertelstunden als Brüche)"

#: prefs.js:83
msgid "Slow time (quarters in natural language)"
msgstr ""

#: prefs.js:84
msgid "ISO date and time (2014-01-30T14:50:10)"
msgstr "Datum und Zeit nach ISO (2014-01-30T14:50:10)"

#: prefs.js:84
#: prefs.js:85
msgid "Local and Internet time"
msgstr "Ortszeit und Internetzeit"

#: prefs.js:85
# In this context silly seems to convey a notion of funny instead of stupid. Hence "albern" instead of "dumm".
#: prefs.js:86
msgid "Something sillier"
msgstr "Etwas Alberneres"

#: prefs.js:85
#: prefs.js:86
msgid "It is %M minutes past hour %H"
msgstr "Es ist %M Minuten nach %H Uhr"

#: prefs.js:120
#: prefs.js:121
#, javascript-format
msgid "What do all these %x codes mean?"
msgstr "Was bedeuten all diese Codes mit %x?"
Loading