Submitter | Sean Farley |
---|---|
Date | Dec. 17, 2014, 12:01 a.m. |
Message ID | <47d0996687d81753386f.1418774515@laptop.local> |
Download | mbox | patch |
Permalink | /patch/7129/ |
State | Changes Requested |
Headers | show |
Comments
> -----Original Message----- > From: Mercurial-devel [mailto:mercurial-devel-bounces@selenic.com] On > Behalf Of Sean Farley > Sent: Tuesday, December 16, 2014 4:02 PM > To: mercurial-devel@selenic.com > Subject: [PATCH 1 of 7] namespaces: add singular name of a namespace > > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # Date 1418630992 28800 > # Mon Dec 15 00:09:52 2014 -0800 > # Node ID 47d0996687d81753386f01e26037be30992dbb59 > # Parent 39cead85fd58ae6693592074656b284ed736d9bc > namespaces: add singular name of a namespace > > Since there is no easy way to get the singular or plural form of a word in the > English language, we store both. This will be used later in the templating > machinery to automatically generate keywords. > > diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py > --- a/mercurial/namespaces.py > +++ b/mercurial/namespaces.py > @@ -24,10 +24,12 @@ class namespaces(object): > not be in its domain. In this case, each method should return an empty list > and not raise an error. > > We'll have a dictionary '_names' where each key is a namespace and > its value is a dictionary of functions: > + 'singular': singular name of the namespace (e.g. "bookmark" > + vs. "bookmarks") > 'namemap': function that takes a name and returns a list of nodes > """ > > _names_version = 0 > > @@ -36,29 +38,32 @@ class namespaces(object): > > addns = self.addnamespace > > # we need current mercurial named objects (bookmarks, tags, and > # branches) to be initialized somewhere, so that place is here > - addns("bookmarks", > + addns("bookmarks", "bookmark", > lambda repo, name: tolist(repo._bookmarks.get(name))) > > - addns("tags", > + addns("tags", "tag", > lambda repo, name: tolist(repo._tagscache.tags.get(name))) > > - addns("branches", > + addns("branches", "branch", > lambda repo, name: tolist(repo.branchtip(name))) Having thought about it, for i18n purposes, I think we should wrap the singular names in the translation bit: _() > > - def addnamespace(self, namespace, namemap, order=None): > + def addnamespace(self, namespace, singular, namemap, order=None): > """ > register a namespace > > namespace: the name to be registered (in plural form) > + singular: the singular naming of namespace (for output, e.g. log, > + templating, etc.) > namemap: function that inputs a node, output name(s) > order: optional argument to specify the order of namespaces > (e.g. 'branches' should be listed before 'bookmarks') > """ > - val = {'namemap': namemap} > + val = {'singular': singular, > + 'namemap': namemap} > if order is not None: > self._names.insert(order, namespace, val) > else: > self._names[namespace] = val > Otherwise looks good to me.
On 12/16/2014 04:01 PM, Sean Farley wrote: > # HG changeset patch > # User Sean Farley <sean.michael.farley@gmail.com> > # Date 1418630992 28800 > # Mon Dec 15 00:09:52 2014 -0800 > # Node ID 47d0996687d81753386f01e26037be30992dbb59 > # Parent 39cead85fd58ae6693592074656b284ed736d9bc > namespaces: add singular name of a namespace > > Since there is no easy way to get the singular or plural form of a word in the > English language, we store both. This will be used later in the templating > machinery to automatically generate keywords. It is not clear to me who you plan to use this singular vs plurals things. But in all case, it seems doomed: http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html Mercurial took the party of not dealing with pluras/singular at all instead. What was your planned usecase.
Ryan McElroy writes: >> -----Original Message----- >> From: Mercurial-devel [mailto:mercurial-devel-bounces@selenic.com] On >> Behalf Of Sean Farley >> Sent: Tuesday, December 16, 2014 4:02 PM >> To: mercurial-devel@selenic.com >> Subject: [PATCH 1 of 7] namespaces: add singular name of a namespace >> >> # HG changeset patch >> # User Sean Farley <sean.michael.farley@gmail.com> >> # Date 1418630992 28800 >> # Mon Dec 15 00:09:52 2014 -0800 >> # Node ID 47d0996687d81753386f01e26037be30992dbb59 >> # Parent 39cead85fd58ae6693592074656b284ed736d9bc >> namespaces: add singular name of a namespace >> >> Since there is no easy way to get the singular or plural form of a word in the >> English language, we store both. This will be used later in the templating >> machinery to automatically generate keywords. >> >> diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py >> --- a/mercurial/namespaces.py >> +++ b/mercurial/namespaces.py >> @@ -24,10 +24,12 @@ class namespaces(object): >> not be in its domain. In this case, each method should return an empty list >> and not raise an error. >> >> We'll have a dictionary '_names' where each key is a namespace and >> its value is a dictionary of functions: >> + 'singular': singular name of the namespace (e.g. "bookmark" >> + vs. "bookmarks") >> 'namemap': function that takes a name and returns a list of nodes >> """ >> >> _names_version = 0 >> >> @@ -36,29 +38,32 @@ class namespaces(object): >> >> addns = self.addnamespace >> >> # we need current mercurial named objects (bookmarks, tags, and >> # branches) to be initialized somewhere, so that place is here >> - addns("bookmarks", >> + addns("bookmarks", "bookmark", >> lambda repo, name: tolist(repo._bookmarks.get(name))) >> >> - addns("tags", >> + addns("tags", "tag", >> lambda repo, name: tolist(repo._tagscache.tags.get(name))) >> >> - addns("branches", >> + addns("branches", "branch", >> lambda repo, name: tolist(repo.branchtip(name))) > > Having thought about it, for i18n purposes, I think we should wrap the singular names in the translation bit: _() Not a bad idea. Would that just be: addns("branches", _("branch"), ...)? Personally, I'd prefer to follow this up with another changeset after the current namespace patches are queued (about 10 more left). If other reviewers push back, though, I can change this and send a V2.
> -----Original Message----- > > On 12/16/2014 04:01 PM, Sean Farley wrote: > > # HG changeset patch > > # User Sean Farley <sean.michael.farley@gmail.com> > > # Date 1418630992 28800 > > # Mon Dec 15 00:09:52 2014 -0800 > > # Node ID 47d0996687d81753386f01e26037be30992dbb59 > > # Parent 39cead85fd58ae6693592074656b284ed736d9bc > > namespaces: add singular name of a namespace > > > > Since there is no easy way to get the singular or plural form of a word in the > > English language, we store both. This will be used later in the templating > > machinery to automatically generate keywords. > > It is not clear to me who you plan to use this singular vs plurals > things. But in all case, it seems doomed: > > https://urldefense.proofpoint.com/v1/url?u=http://localization- > guide.readthedocs.org/en/latest/l10n/pluralforms.html&k=ZVNjlDMF0FElm4 > dQtryO4A%3D%3D%0A&r=zxRJZ6melt%2FqLtQ%2Bw2Gaeg%3D%3D%0A&m > =cyH8RfyIdDLS3V4%2FEMiEwnoeXRdUqxndP5EzbUo%2BFJo%3D%0A&s=2f5 > 6edb60246c22bf13d8f8ba7232242a3038a04d501ebc1b4f7add623f975e0 > > Mercurial took the party of not dealing with pluras/singular at all instead. > > What was your planned usecase. > I think it's not doomed, it probably just needs to be renamed. This stuff is going to be used in the log output, which in English we identify as singular versions: changeset: 23787:9b18fe88820e bookmark: foo bookmark: bar tag: tip ... So it could be called 'logname' and I think we can avoid all the issues with singular/plural internationalization. ~Ryan
Pierre-Yves David writes: > On 12/16/2014 04:01 PM, Sean Farley wrote: >> # HG changeset patch >> # User Sean Farley <sean.michael.farley@gmail.com> >> # Date 1418630992 28800 >> # Mon Dec 15 00:09:52 2014 -0800 >> # Node ID 47d0996687d81753386f01e26037be30992dbb59 >> # Parent 39cead85fd58ae6693592074656b284ed736d9bc >> namespaces: add singular name of a namespace >> >> Since there is no easy way to get the singular or plural form of a word in the >> English language, we store both. This will be used later in the templating >> machinery to automatically generate keywords. > > It is not clear to me who you plan to use this singular vs plurals > things. But in all case, it seems doomed: > > http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html > > Mercurial took the party of not dealing with pluras/singular at all instead. Oh, then why translate the singular form at all? > What was your planned usecase. It's in patch 5 of 7 [templatekw: add helper method to generate a template keyword for a namespace], return showlist(repo.names.singular(namespace), names, plural=namespace, **args)
On 12/16/2014 05:51 PM, Ryan McElroy wrote: >> -----Original Message----- >> >> On 12/16/2014 04:01 PM, Sean Farley wrote: >>> # HG changeset patch >>> # User Sean Farley <sean.michael.farley@gmail.com> >>> # Date 1418630992 28800 >>> # Mon Dec 15 00:09:52 2014 -0800 >>> # Node ID 47d0996687d81753386f01e26037be30992dbb59 >>> # Parent 39cead85fd58ae6693592074656b284ed736d9bc >>> namespaces: add singular name of a namespace >>> >>> Since there is no easy way to get the singular or plural form of a word in the >>> English language, we store both. This will be used later in the templating >>> machinery to automatically generate keywords. >> >> It is not clear to me who you plan to use this singular vs plurals >> things. But in all case, it seems doomed: >> >> https://urldefense.proofpoint.com/v1/url?u=http://localization- >> guide.readthedocs.org/en/latest/l10n/pluralforms.html&k=ZVNjlDMF0FElm4 >> dQtryO4A%3D%3D%0A&r=zxRJZ6melt%2FqLtQ%2Bw2Gaeg%3D%3D%0A&m >> =cyH8RfyIdDLS3V4%2FEMiEwnoeXRdUqxndP5EzbUo%2BFJo%3D%0A&s=2f5 >> 6edb60246c22bf13d8f8ba7232242a3038a04d501ebc1b4f7add623f975e0 >> >> Mercurial took the party of not dealing with pluras/singular at all instead. >> >> What was your planned usecase. >> > > I think it's not doomed, it probably just needs to be renamed. This stuff is going to be used in the log output, which in English we identify as singular versions: > > changeset: 23787:9b18fe88820e > bookmark: foo > bookmark: bar > tag: tip > ... > > So it could be called 'logname' and I think we can avoid all the issues with singular/plural internationalization. It ia apparently also used for template keywork. So it sound like a generic user visible label.
Pierre-Yves David writes: > On 12/16/2014 05:51 PM, Ryan McElroy wrote: >>> -----Original Message----- >>> >>> On 12/16/2014 04:01 PM, Sean Farley wrote: >>>> # HG changeset patch >>>> # User Sean Farley <sean.michael.farley@gmail.com> >>>> # Date 1418630992 28800 >>>> # Mon Dec 15 00:09:52 2014 -0800 >>>> # Node ID 47d0996687d81753386f01e26037be30992dbb59 >>>> # Parent 39cead85fd58ae6693592074656b284ed736d9bc >>>> namespaces: add singular name of a namespace >>>> >>>> Since there is no easy way to get the singular or plural form of a word in the >>>> English language, we store both. This will be used later in the templating >>>> machinery to automatically generate keywords. >>> >>> It is not clear to me who you plan to use this singular vs plurals >>> things. But in all case, it seems doomed: >>> >>> https://urldefense.proofpoint.com/v1/url?u=http://localization- >>> guide.readthedocs.org/en/latest/l10n/pluralforms.html&k=ZVNjlDMF0FElm4 >>> dQtryO4A%3D%3D%0A&r=zxRJZ6melt%2FqLtQ%2Bw2Gaeg%3D%3D%0A&m >>> =cyH8RfyIdDLS3V4%2FEMiEwnoeXRdUqxndP5EzbUo%2BFJo%3D%0A&s=2f5 >>> 6edb60246c22bf13d8f8ba7232242a3038a04d501ebc1b4f7add623f975e0 >>> >>> Mercurial took the party of not dealing with pluras/singular at all instead. >>> >>> What was your planned usecase. >>> >> >> I think it's not doomed, it probably just needs to be renamed. This stuff is going to be used in the log output, which in English we identify as singular versions: >> >> changeset: 23787:9b18fe88820e >> bookmark: foo >> bookmark: bar >> tag: tip >> ... >> >> So it could be called 'logname' and I think we can avoid all the issues with singular/plural internationalization. > > It ia apparently also used for template keywork. So it sound like a > generic user visible label. So, for templates we don't translate the singular / plural names. Here's a crazy idea: Since we aren't preserving the order in log output (unsent patch), how about we not mess with translation (leave the branch, bookmark, tag log output as is) and just append to the end of that list? Otherwise, I think Ryan is right and we'll have to have another variable for log output that is translated (if I am understanding correctly).
On 12/16/2014 07:05 PM, Sean Farley wrote: > > Pierre-Yves David writes: > >> On 12/16/2014 05:51 PM, Ryan McElroy wrote: >>>> -----Original Message----- >>>> >>>> On 12/16/2014 04:01 PM, Sean Farley wrote: >>>>> # HG changeset patch >>>>> # User Sean Farley <sean.michael.farley@gmail.com> >>>>> # Date 1418630992 28800 >>>>> # Mon Dec 15 00:09:52 2014 -0800 >>>>> # Node ID 47d0996687d81753386f01e26037be30992dbb59 >>>>> # Parent 39cead85fd58ae6693592074656b284ed736d9bc >>>>> namespaces: add singular name of a namespace >>>>> >>>>> Since there is no easy way to get the singular or plural form of a word in the >>>>> English language, we store both. This will be used later in the templating >>>>> machinery to automatically generate keywords. >>>> >>>> It is not clear to me who you plan to use this singular vs plurals >>>> things. But in all case, it seems doomed: >>>> >>>> https://urldefense.proofpoint.com/v1/url?u=http://localization- >>>> guide.readthedocs.org/en/latest/l10n/pluralforms.html&k=ZVNjlDMF0FElm4 >>>> dQtryO4A%3D%3D%0A&r=zxRJZ6melt%2FqLtQ%2Bw2Gaeg%3D%3D%0A&m >>>> =cyH8RfyIdDLS3V4%2FEMiEwnoeXRdUqxndP5EzbUo%2BFJo%3D%0A&s=2f5 >>>> 6edb60246c22bf13d8f8ba7232242a3038a04d501ebc1b4f7add623f975e0 >>>> >>>> Mercurial took the party of not dealing with pluras/singular at all instead. >>>> >>>> What was your planned usecase. >>>> >>> >>> I think it's not doomed, it probably just needs to be renamed. This stuff is going to be used in the log output, which in English we identify as singular versions: >>> >>> changeset: 23787:9b18fe88820e >>> bookmark: foo >>> bookmark: bar >>> tag: tip >>> ... >>> >>> So it could be called 'logname' and I think we can avoid all the issues with singular/plural internationalization. >> >> It ia apparently also used for template keywork. So it sound like a >> generic user visible label. > > So, for templates we don't translate the singular / plural names. > > Here's a crazy idea: > > Since we aren't preserving the order in log output (unsent patch), how > about we not mess with translation (leave the branch, bookmark, tag log > output as is) and just append to the end of that list? > > Otherwise, I think Ryan is right and we'll have to have another variable > for log output that is translated (if I am understanding correctly). So after reading the whole series I get this variable is about the label we use for template. Maybe we could name that 'templatelabel' as a start (or something similar). From this, I foresee that namespace will have a lots of different attribute. From there it -may- start to make sense to have an object for each namespace. Lets get this series in without object and decide if we want it later or not.
So there are basically three things, right? 1) namespace name (branches, bookmarks, tags -- not translated) 2) log name (branch, bookmark, tag -- translated to local language) 3) template keyword (branch, bookmark, tag -- not translated) Let's create each of them for now, as needed. ~Ryan > -----Original Message----- > From: Pierre-Yves David [mailto:pierre-yves.david@ens-lyon.org] > Sent: Tuesday, December 16, 2014 11:19 PM > To: Sean Farley > Cc: mercurial-devel@selenic.com; Ryan McElroy > Subject: Re: [PATCH 1 of 7] namespaces: add singular name of a namespace > > > > On 12/16/2014 07:05 PM, Sean Farley wrote: > > > > Pierre-Yves David writes: > > > >> On 12/16/2014 05:51 PM, Ryan McElroy wrote: > >>>> -----Original Message----- > >>>> > >>>> On 12/16/2014 04:01 PM, Sean Farley wrote: > >>>>> # HG changeset patch > >>>>> # User Sean Farley <sean.michael.farley@gmail.com> > >>>>> # Date 1418630992 28800 > >>>>> # Mon Dec 15 00:09:52 2014 -0800 > >>>>> # Node ID 47d0996687d81753386f01e26037be30992dbb59 > >>>>> # Parent 39cead85fd58ae6693592074656b284ed736d9bc > >>>>> namespaces: add singular name of a namespace > >>>>> > >>>>> Since there is no easy way to get the singular or plural form of a word > in the > >>>>> English language, we store both. This will be used later in the > templating > >>>>> machinery to automatically generate keywords. > >>>> > >>>> It is not clear to me who you plan to use this singular vs plurals > >>>> things. But in all case, it seems doomed: > >>>> > >>>> https://urldefense.proofpoint.com/v1/url?u=http://localization- > >>>> > guide.readthedocs.org/en/latest/l10n/pluralforms.html&k=ZVNjlDMF0FElm4 > >>>> > dQtryO4A%3D%3D%0A&r=zxRJZ6melt%2FqLtQ%2Bw2Gaeg%3D%3D%0A&m > >>>> > =cyH8RfyIdDLS3V4%2FEMiEwnoeXRdUqxndP5EzbUo%2BFJo%3D%0A&s=2f5 > >>>> 6edb60246c22bf13d8f8ba7232242a3038a04d501ebc1b4f7add623f975e0 > >>>> > >>>> Mercurial took the party of not dealing with pluras/singular at all > instead. > >>>> > >>>> What was your planned usecase. > >>>> > >>> > >>> I think it's not doomed, it probably just needs to be renamed. This stuff > is going to be used in the log output, which in English we identify as singular > versions: > >>> > >>> changeset: 23787:9b18fe88820e > >>> bookmark: foo > >>> bookmark: bar > >>> tag: tip > >>> ... > >>> > >>> So it could be called 'logname' and I think we can avoid all the issues with > singular/plural internationalization. > >> > >> It ia apparently also used for template keywork. So it sound like a > >> generic user visible label. > > > > So, for templates we don't translate the singular / plural names. > > > > Here's a crazy idea: > > > > Since we aren't preserving the order in log output (unsent patch), how > > about we not mess with translation (leave the branch, bookmark, tag log > > output as is) and just append to the end of that list? > > > > Otherwise, I think Ryan is right and we'll have to have another variable > > for log output that is translated (if I am understanding correctly). > > So after reading the whole series I get this variable is about the label > we use for template. Maybe we could name that 'templatelabel' as a start > (or something similar). > > From this, I foresee that namespace will have a lots of different > attribute. From there it -may- start to make sense to have an object for > each namespace. > > Lets get this series in without object and decide if we want it later or > not. > > -- > Pierre-Yves David
Patch
diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py --- a/mercurial/namespaces.py +++ b/mercurial/namespaces.py @@ -24,10 +24,12 @@ class namespaces(object): not be in its domain. In this case, each method should return an empty list and not raise an error. We'll have a dictionary '_names' where each key is a namespace and its value is a dictionary of functions: + 'singular': singular name of the namespace (e.g. "bookmark" + vs. "bookmarks") 'namemap': function that takes a name and returns a list of nodes """ _names_version = 0 @@ -36,29 +38,32 @@ class namespaces(object): addns = self.addnamespace # we need current mercurial named objects (bookmarks, tags, and # branches) to be initialized somewhere, so that place is here - addns("bookmarks", + addns("bookmarks", "bookmark", lambda repo, name: tolist(repo._bookmarks.get(name))) - addns("tags", + addns("tags", "tag", lambda repo, name: tolist(repo._tagscache.tags.get(name))) - addns("branches", + addns("branches", "branch", lambda repo, name: tolist(repo.branchtip(name))) - def addnamespace(self, namespace, namemap, order=None): + def addnamespace(self, namespace, singular, namemap, order=None): """ register a namespace namespace: the name to be registered (in plural form) + singular: the singular naming of namespace (for output, e.g. log, + templating, etc.) namemap: function that inputs a node, output name(s) order: optional argument to specify the order of namespaces (e.g. 'branches' should be listed before 'bookmarks') """ - val = {'namemap': namemap} + val = {'singular': singular, + 'namemap': namemap} if order is not None: self._names.insert(order, namespace, val) else: self._names[namespace] = val