Re: [Freeipa-devel] [PATCH 69] Use indexed format specifiers in i18n strings

2012-04-11 Thread Rob Crittenden

John Dennis wrote:

On 04/04/2012 09:01 AM, Petr Viktorin wrote:

On 04/02/2012 03:15 PM, Rob Crittenden wrote:

John Dennis wrote:

Translators need to reorder messages to suit the needs of the target
language. The conventional positional format specifiers (e.g. %s %d)
do not permit reordering because their order is tied to the ordering
of the arguments to the printf function. The fix is to use indexed
format specifiers.


I guess this looks ok but all of these errors are of the format: string
error, error number (and inconsistently, sometimes the reverse).


Not all of them, e.g.

- fprintf(stderr, _(Search for %s on rootdse failed with error %d),
+ fprintf(stderr, _(Search for %1$s on rootdse failed with error
%2$d\n),
root_attrs[0], ret);

- fprintf(stderr, _(Failed to open keytab '%s': %s\n), keytab,
+ fprintf(stderr, _(Failed to open keytab '%1$s': %2$s\n), keytab,
error_message(krberr));


Do those really need to be re-orderable?



You can never make too few assumptions about foreign languages. Most
likely at least some will need reordering.
Enforcing indexed specifiers everywhere means we don't have to worry
about individual cases, or change our strings when a new language is
added.


+1

But there is also another practical reason. The validation logic does
not have artificial intelligence and cannot parse the semantic intent of
the string. It only knows if there are multiple non-indexed specifiers.

If we want to automatically validate strings (make lint) from another
patch, we have to live with rigid application of the rules (adding
exception logic to the validator would be pretty complex because unlike
lint there is no way to tag the string that would get carried all the
way thought the xgettext process and be visible to the validator).


I'm still not convinced that another language would want to reorder 
these but it does no harm so ACK.


pushed to master and ipa-2-2

rob

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 69] Use indexed format specifiers in i18n strings

2012-04-05 Thread John Dennis

On 04/04/2012 09:01 AM, Petr Viktorin wrote:

On 04/02/2012 03:15 PM, Rob Crittenden wrote:

John Dennis wrote:

Translators need to reorder messages to suit the needs of the target
language. The conventional positional format specifiers (e.g. %s %d)
do not permit reordering because their order is tied to the ordering
of the arguments to the printf function. The fix is to use indexed
format specifiers.


I guess this looks ok but all of these errors are of the format: string
error, error number (and inconsistently, sometimes the reverse).


Not all of them, e.g.

- fprintf(stderr, _(Search for %s on rootdse failed with error %d),
+ fprintf(stderr, _(Search for %1$s on rootdse failed with error %2$d\n),
   root_attrs[0], ret);

- fprintf(stderr, _(Failed to open keytab '%s': %s\n), keytab,
+ fprintf(stderr, _(Failed to open keytab '%1$s': %2$s\n), keytab,
error_message(krberr));


Do those really need to be re-orderable?



You can never make too few assumptions about foreign languages. Most
likely at least some will need reordering.
Enforcing indexed specifiers everywhere means we don't have to worry
about individual cases, or change our strings when a new language is added.


+1

But there is also another practical reason. The validation logic does 
not have artificial intelligence and cannot parse the semantic intent of 
the string. It only knows if there are multiple non-indexed specifiers.


If we want to automatically validate strings (make lint) from another 
patch, we have to live with rigid application of the rules (adding 
exception logic to the validator would be pretty complex because unlike 
lint there is no way to tag the string that would get carried all the 
way thought the xgettext process and be visible to the validator).



--
John Dennis jden...@redhat.com

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 69] Use indexed format specifiers in i18n strings

2012-04-04 Thread Petr Viktorin

On 04/02/2012 03:15 PM, Rob Crittenden wrote:

John Dennis wrote:

Translators need to reorder messages to suit the needs of the target
language. The conventional positional format specifiers (e.g. %s %d)
do not permit reordering because their order is tied to the ordering
of the arguments to the printf function. The fix is to use indexed
format specifiers.


I guess this looks ok but all of these errors are of the format: string
error, error number (and inconsistently, sometimes the reverse).


Not all of them, e.g.

- fprintf(stderr, _(Search for %s on rootdse failed with error %d),
+ fprintf(stderr, _(Search for %1$s on rootdse failed with error %2$d\n),
 root_attrs[0], ret);

- fprintf(stderr, _(Failed to open keytab '%s': %s\n), keytab,
+ fprintf(stderr, _(Failed to open keytab '%1$s': %2$s\n), keytab,
  error_message(krberr));


Do those really need to be re-orderable?



You can never make too few assumptions about foreign languages. Most 
likely at least some will need reordering.
Enforcing indexed specifiers everywhere means we don't have to worry 
about individual cases, or change our strings when a new language is added.



--
PetrĀ³

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH 69] Use indexed format specifiers in i18n strings

2012-04-02 Thread Rob Crittenden

John Dennis wrote:

Translators need to reorder messages to suit the needs of the target
language. The conventional positional format specifiers (e.g. %s %d)
do not permit reordering because their order is tied to the ordering
of the arguments to the printf function. The fix is to use indexed
format specifiers.


I guess this looks ok but all of these errors are of the format: string 
error, error number (and inconsistently, sometimes the reverse). Do 
those really need to be re-orderable?


rob

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH 69] Use indexed format specifiers in i18n strings

2012-03-29 Thread John Dennis
Translators need to reorder messages to suit the needs of the target
language. The conventional positional format specifiers (e.g. %s %d)
do not permit reordering because their order is tied to the ordering
of the arguments to the printf function. The fix is to use indexed
format specifiers.

--
John Dennis jden...@redhat.com

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
From 02fbab6602c545f0eb3dc4a455955f904d5b53fc Mon Sep 17 00:00:00 2001
From: John Dennis jden...@redhat.com
Date: Thu, 29 Mar 2012 21:34:19 -0400
Subject: [PATCH 69] Use indexed format specifiers in i18n strings
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Translators need to reorder messages to suit the needs of the target
language. The conventional positional format specifiers (e.g. %s %d)
do not permit reordering because their order is tied to the ordering
of the arguments to the printf function. The fix is to use indexed
format specifiers.
---
 ipa-client/ipa-getkeytab.c |   12 ++--
 ipa-client/ipa-join.c  |6 +++---
 ipa-client/ipa-rmkeytab.c  |   14 +++---
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/ipa-client/ipa-getkeytab.c b/ipa-client/ipa-getkeytab.c
index 05e57bb..7d7b971 100644
--- a/ipa-client/ipa-getkeytab.c
+++ b/ipa-client/ipa-getkeytab.c
@@ -82,7 +82,7 @@ static int ldap_sasl_interact(LDAP *ld, unsigned flags, void *priv_data, void *s
 			krberr = krb5_init_context(krbctx);
 
 			if (krberr) {
-fprintf(stderr, _(Kerberos context initialization failed: %s (%d)\n),
+fprintf(stderr, _(Kerberos context initialization failed: %1$s (%2$d)\n),
 error_message(krberr), krberr);
 in-result = NULL;
 in-len = 0;
@@ -93,7 +93,7 @@ static int ldap_sasl_interact(LDAP *ld, unsigned flags, void *priv_data, void *s
 			krberr = krb5_unparse_name(krbctx, princ, outname);
 
 			if (krberr) {
-fprintf(stderr, _(Unable to parse principal: %s (%d)\n),
+fprintf(stderr, _(Unable to parse principal: %1$s (%2$d)\n),
 error_message(krberr), krberr);
 in-result = NULL;
 in-len = 0;
@@ -511,7 +511,7 @@ static int ipa_ldap_init(LDAP ** ld, const char * scheme, const char * servernam
 {
 	char* url = NULL;
 	int  url_len = snprintf(url,0,%s://%s:%d,scheme,servername,port) +1;
-   
+
 	url = (char *)malloc (url_len);
 	if (!url){
 		fprintf(stderr, _(Out of memory \n));
@@ -570,7 +570,7 @@ static int ldap_set_keytab(krb5_context krbctx,
 		if (ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, /etc/ipa/ca.crt) != LDAP_OPT_SUCCESS) {
 			goto error_out;
 		}
- 
+
 		if ( ipa_ldap_init(ld, ldaps,servername, 636) != LDAP_SUCCESS){
 		  goto error_out;
 		}
@@ -579,7 +579,7 @@ static int ldap_set_keytab(krb5_context krbctx,
 		}
 	} else {
 		if (ipa_ldap_init(ld, ldap,servername, 389) != LDAP_SUCCESS){
-			goto error_out;			
+			goto error_out;
 		}
 	}
 
@@ -731,7 +731,7 @@ static int ldap_set_keytab(krb5_context krbctx,
 	keys-ksdata[i].enctype);
 			} else {
 fprintf(stderr, _(Failed to retrieve 
-	encryption type %s (#%d)\n),
+	encryption type %1$s (#%2$d)\n),
 	enc, keys-ksdata[i].enctype);
 			}
 } else {
diff --git a/ipa-client/ipa-join.c b/ipa-client/ipa-join.c
index bc46e93..4c37113 100644
--- a/ipa-client/ipa-join.c
+++ b/ipa-client/ipa-join.c
@@ -108,7 +108,7 @@ static int check_perms(const char *keytab)
 break;
 default:
 fprintf(stderr,
-_(access() on %s failed: errno = %d\n),
+_(access() on %1$s failed: errno = %2$d\n),
 keytab, errno);
 break;
 }
@@ -334,7 +334,7 @@ get_root_dn(const char *ipaserver, char **ldap_base)
 NULL, NULL, NULL, 0, res);
 
 if (ret != LDAP_SUCCESS) {
-fprintf(stderr, _(Search for %s on rootdse failed with error %d),
+fprintf(stderr, _(Search for %1$s on rootdse failed with error %2$d\n),
 root_attrs[0], ret);
 rval = 14;
 goto done;
@@ -801,7 +801,7 @@ unenroll_host(const char *server, const char *hostname, const char *ktname, int
 krberr = krb5_parse_name(krbctx, principal, princ);
 if (krberr != 0) {
 if (!quiet)
-fprintf(stderr, _(Error parsing \%s\: %s.\n),
+fprintf(stderr, _(Error parsing \%1$s\: %2$s.\n),
 principal, error_message(krberr));
 return krberr;
 }
diff --git a/ipa-client/ipa-rmkeytab.c b/ipa-client/ipa-rmkeytab.c
index a6a68ea..a2a292e 100644
--- a/ipa-client/ipa-rmkeytab.c
+++ b/ipa-client/ipa-rmkeytab.c
@@ -42,7 +42,7 @@ remove_principal(krb5_context context, krb5_keytab ktid, const char *principal,
 if (krberr) {
 fprintf(stderr, _(Unable to parse principal name\n));
 if (debug)
-fprintf(stderr, _(krb5_parse_name %d: %s\n),
+