2012-04-30 21 views
6

Estoy intentando traducir mi aplicación y me resulta difícil traducirla cuando hay medio marcador de posición. Tengo que busque el código siguiente:Marcador de posición y NSLocalizedString

[textView1 insertText:[NSString stringWithFormat:@"%@ è il %i/%i/%i. Il giorno delle settimana è %@. La Festa è compresa nel calcolo. \n", nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]]; 

pongo en el localizable.string archivo (Inglés):

"festaCompresa" = @"%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n"; 

Luego he editado el trozo de código:

[textView1 insertText:[NSString stringWithFormat:NSLocalizedString(@"festaCompresaW, @""), nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]]; 

Se No funciona.

+0

Cómo exactamente no funciona? – hamstergene

+0

La visualización de la pantalla no es correcta porque la palabra comparar: festaCompresaW – Andrea

+0

También hay un error en el archivo. cadena: Validación fallida: los datos no se pudieron leer porque se han dañado. – Andrea

Respuesta

4

¿Copió y pegó el código? ¿O lo reescribió? Porque si copia-pegado que el problema está ahí:

[textView1 insertText:[NSString stringWithFormat:NSLocalizedString(@"festaCompresaW, @""), nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]]; 

supongo que debe ser

[textView1 insertText:[NSString stringWithFormat:NSLocalizedString(@"festaCompresa", @""), nomeFesta, giornoFesta, meseFesta, annoFestaModificato, ggSett]]; 

Así que, básicamente, un " en lugar de W.

Además, en Localizable.strings que no pongan @ delante de las comillas, por lo que este:

"festaCompresa" = @"%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n"; 

debe ser la siguiente:

"festaCompresa" = "%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n"; 

creo que sirve

6

Su archivo de cadenas tiene un error menor, que ha incluido un @ como si la cadena como una constante NSString - el formato de archivo utiliza cadenas entre comillas:

"festaCompresa" = "%@ is the %i/%i/%i. the day of the week is %@. The holidays is included in the calculation. \n"; 

Por cierto: al crear cadenas de formato para la localización Es posible que necesite utilizar posicional formatos donde cada especificación de formato incluye el número del argumento. Por ejemplo:

"festaCompresa" = "%[email protected] is the %2$i/%3$i/%4$i. the day of the week is %@. The holidays is included in the calculation. \n"; 

Esto obviamente no es necesaria en la cadena de más arriba como los argumentos están incluidas en el orden en que se proporcionan. Sin embargo, en algunos idiomas pueden necesitar estar en un orden diferente y así es como se hace.

Cuestiones relacionadas