Merge pull request #592 from GetStream/localization-es

feat(localization): Support for Spanish
This commit is contained in:
Salvatore Giordano
2021-08-06 12:30:10 +02:00
committed by GitHub
7 changed files with 396 additions and 10 deletions
@@ -25,6 +25,7 @@ At the moment we support the following languages:
- [Hindi](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart)
- [Italian](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart)
- [French](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart)
- [Spanish](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart)
More languages will be added in the future. Feel free to [contribute](https://github.com/GetStream/stream-chat-flutter/blob/master/CONTRIBUTING.md) to add more languages.
@@ -62,6 +63,7 @@ class MyApp extends StatelessWidget {
Locale('hi'),
Locale('fr'),
Locale('it'),
Locale('es'),
],
// Add GlobalStreamChatLocalizations.delegates
localizationsDelegates: GlobalStreamChatLocalizations.delegates,
@@ -130,6 +132,7 @@ Here is an example of how that would look like:
Locale('hi'),
Locale('fr'),
Locale('it'),
Locale('es'),
],
// locales are the locales of the device
// supportedLocales are the app supported locales
@@ -172,5 +175,6 @@ Example:
<string>nb</string>
<string>fr</string>
<string>it</string>
<string>es</string>
</array>
```
@@ -73,6 +73,7 @@ class MyApp extends StatelessWidget {
Locale('hi'),
Locale('fr'),
Locale('it'),
Locale('es'),
],
localizationsDelegates: GlobalStreamChatLocalizations.delegates,
builder: (context, widget) => StreamChat(
@@ -1,6 +1,10 @@
## Upcoming
* Added support for [Spanish](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart) locale.
## 1.0.2
* Updated stream_chat_flutter dependency
* Updated `stream_chat_flutter` dependency
## 1.0.1
@@ -8,4 +12,8 @@
## 1.0.0
* First release
* Initial Release with support for 4 locales
- [English](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart)
- [Hindi](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart)
- [Italian](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart)
- [French](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart)
+5 -2
View File
@@ -34,6 +34,7 @@ At the moment we support the following languages:
- [Hindi](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart)
- [Italian](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart)
- [French](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart)
- [Spanish](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/lib/src/stream_chat_localizations_es.dart)
More languages will be added in the future. Feel free to [contribute](https://github.com/GetStream/stream-chat-flutter/blob/master/CONTRIBUTING.md) to add more languages.
@@ -68,6 +69,7 @@ class MyApp extends StatelessWidget {
Locale('hi'),
Locale('fr'),
Locale('it'),
Locale('es'),
],
// Add GlobalStreamChatLocalizations.delegates
localizationsDelegates: GlobalStreamChatLocalizations.delegates,
@@ -86,13 +88,13 @@ class MyApp extends StatelessWidget {
### Adding a new language
To add a new language, you need to create a new class extending `GlobalStreamChatLocalizations` and create a delegate for it adding it to the `delegates` array.
To add a new language, create a new class extending `GlobalStreamChatLocalizations` and create a delegate for it, adding it to the `delegates` array.
Check out [this example](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/example/lib/add_new_lang.dart) to see how to add a new language.
### Override existing languages
To override an existing language, you need to create a new class extending that particular language class and create a delegate for it adding it to the `delegates` array.
To override an existing language, create a new class extending that particular language class and create a delegate for it, adding it to the `delegates` array.
Check out [this example](https://github.com/GetStream/stream-chat-flutter/blob/master/packages/stream_chat_localizations/example/lib/override_lang.dart) to see how to override an existing language.
@@ -110,6 +112,7 @@ Example:
<string>nb</string>
<string>fr</string>
<string>it</string>
<string>es</string>
</array>
```
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
part 'stream_chat_localizations_es.dart';
part 'stream_chat_localizations_en.dart';
part 'stream_chat_localizations_fr.dart';
@@ -24,6 +26,7 @@ const kStreamChatSupportedLanguages = {
'hi',
'fr',
'it',
'es',
};
/// Creates a [GlobalStreamChatLocalizations] instance for the given `locale`.
@@ -54,6 +57,8 @@ GlobalStreamChatLocalizations? getStreamChatTranslation(Locale locale) {
return const StreamChatLocalizationsFr();
case 'it':
return const StreamChatLocalizationsIt();
case 'es':
return const StreamChatLocalizationsEs();
}
}
@@ -0,0 +1,365 @@
part of 'stream_chat_localizations.dart';
/// The translations for Spanish (`es`).
class StreamChatLocalizationsEs extends GlobalStreamChatLocalizations {
/// Create an instance of the translation bundle for Spanish.
const StreamChatLocalizationsEs({String localeName = 'es'})
: super(localeName: localeName);
@override
String get launchUrlError => 'No se pudo abrir la url';
@override
String get loadingUsersError => 'Error de carga del usuario';
@override
String get noUsersLabel => 'No hay usuarios actualmente';
@override
String get retryLabel => 'Inténtelo de nuevo';
@override
String get userLastOnlineText => 'Última vez en línea';
@override
String get userOnlineText => 'En línea';
@override
String userTypingText(Iterable<User> users) {
if (users.isEmpty) return '';
final first = users.first;
if (users.length == 1) {
return '${first.name} está escribiendo';
}
return '${first.name} y ${users.length - 1} están escribiendo';
}
@override
String get threadReplyLabel => 'Responder al hilo de discusión';
@override
String get onlyVisibleToYouText => 'Sólo visible para usted';
@override
String threadReplyCountText(int count) =>
'$count respuestas al hilo de discusión';
@override
String attachmentsUploadProgressText({
required int remaining,
required int total,
}) =>
'Transferencia en curso $remaining/$total ...';
@override
String pinnedByUserText({
required User pinnedBy,
required User currentUser,
}) {
final pinnedByCurrentUser = currentUser.id == pinnedBy.id;
if (pinnedByCurrentUser) return 'Fijado por ti';
return 'Fijado por ${pinnedBy.name}';
}
@override
String get emptyMessagesText => 'Actualmente no hay mensajes';
@override
String get genericErrorText => 'Hubo un problema';
@override
String get loadingMessagesError =>
'Hubo un error mientras se cargaba el mensaje';
@override
String resultCountText(int count) => '$count resultados';
@override
String get messageDeletedText => 'Este mensaje ha sido borrado.';
@override
String get messageDeletedLabel => 'Mensaje borrado';
@override
String get messageReactionsLabel => 'Reacciones a los mensajes';
@override
String get emptyChatMessagesText => 'Todavía no hay charlas aquí...';
@override
String threadSeparatorText(int replyCount) {
if (replyCount == 1) return '1 respuesta';
return '$replyCount respuestas';
}
@override
String get connectedLabel => 'Conectado';
@override
String get disconnectedLabel => 'Desconectado';
@override
String get reconnectingLabel => 'Reconectando...';
@override
String get alsoSendAsDirectMessageLabel =>
'Enviar también como mensaje directo';
@override
String get addACommentOrSendLabel => 'Añadir un comentario o enviar';
@override
String get searchGifLabel => 'Búsqueda de GIFs';
@override
String get writeAMessageLabel => 'Escribir un mensaje';
@override
String get instantCommandsLabel => 'Comandos instantáneos';
@override
String fileTooLargeAfterCompressionError(double limitInMB) =>
'El archivo es demasiado grande para descargarlo. '
'El tamaño máximo del archivo es de $limitInMB MB. '
'Intentamos comprimirlo, pero no fue suficiente.';
@override
String fileTooLargeError(double limitInMB) =>
'El archivo es demasiado grande para descargarlo. '
'El límite de tamaño de los archivos es de $limitInMB MB.';
@override
String emojiMatchingQueryText(String query) =>
'Emoji que corresponde a "$query"';
@override
String get addAFileLabel => 'Añadir un archivo';
@override
String get photoFromCameraLabel => 'Foto de la cámara';
@override
String get uploadAFileLabel => 'Transferir un archivo';
@override
String get uploadAPhotoLabel => 'Subir una foto';
@override
String get uploadAVideoLabel => 'Subir una vídeo';
@override
String get videoFromCameraLabel => 'Vídeo de la cámara';
@override
String get okLabel => 'Vale';
@override
String get somethingWentWrongError => 'Algo ha salido mal';
@override
String get addMoreFilesLabel => 'Añadir más archivos';
@override
String get enablePhotoAndVideoAccessMessage =>
'Por favor, permita el acceso a sus fotos'
'\ny vídeos para que puedas compartirlos con sus amigos.';
@override
String get allowGalleryAccessMessage => 'Permitir el acceso a su galería';
@override
String get flagMessageLabel => 'Reportar un mensaje';
@override
String get flagMessageQuestion =>
'¿Quiere enviar una copia de este mensaje a un'
'\nmoderador para una mayor investigación?';
@override
String get flagLabel => 'REPORTAR';
@override
String get cancelLabel => 'CANCELAR';
@override
String get flagMessageSuccessfulLabel => 'Mensaje reportado';
@override
String get flagMessageSuccessfulText =>
'Este mensaje ha sido reportado a un moderador.';
@override
String get deleteLabel => 'BORRAR';
@override
String get deleteMessageLabel => 'Borrar el mensaje';
@override
String get deleteMessageQuestion =>
'¿Estás seguro de que quieres borrar este\nmensaje de forma permanente?';
@override
String get operationCouldNotBeCompletedText =>
'La operación no pudo completarse.';
@override
String get replyLabel => 'Respuesta';
@override
String togglePinUnpinText({required bool pinned}) {
if (pinned) return 'Desfijar a la conversación';
return 'Fijar a la conversación';
}
@override
String toggleDeleteRetryDeleteMessageText({required bool isDeleteFailed}) {
if (isDeleteFailed) return 'Reintentar borrar el mensaje';
return 'Borrar el mensaje';
}
@override
String get copyMessageLabel => 'Copiar el mensaje';
@override
String get editMessageLabel => 'Editar el mensaje';
@override
String toggleResendOrResendEditedMessage({required bool isUpdateFailed}) {
if (isUpdateFailed) return 'Reenviar el mensaje modificado';
return 'Reenviar';
}
@override
String get photosLabel => 'Fotos';
String _getDay(DateTime dateTime) {
final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
final yesterday = DateTime(now.year, now.month, now.day - 1);
final date = DateTime(dateTime.year, dateTime.month, dateTime.day);
if (date == today) {
return 'hoy';
} else if (date == yesterday) {
return 'ayer';
} else {
return 'el ${Jiffy(date).MMMd}';
}
}
@override
String sentAtText({required DateTime date, required DateTime time}) =>
'''Enviado el ${_getDay(date)} a las ${Jiffy(time.toLocal()).format('HH:mm')}''';
@override
String get todayLabel => 'Hoy';
@override
String get yesterdayLabel => 'Ayer';
@override
String get channelIsMutedText => 'El canal está silenciado';
@override
String get noTitleText => 'Sin título';
@override
String get letsStartChattingLabel => '¡Empecemos a charlar!';
@override
String get sendingFirstMessageLabel =>
'¿Qué le parece enviar su primer mensaje a un amigo?';
@override
String get startAChatLabel => 'Iniciar una conversación';
@override
String get loadingChannelsError => 'Error al cargar los canales';
@override
String get deleteConversationLabel => 'Borrar la conversación';
@override
String get deleteConversationQuestion =>
'¿Estás seguro de que quieres borrar esta conversación?';
@override
String get streamChatLabel => 'Stream Chat';
@override
String get searchingForNetworkText => 'Buscando red';
@override
String get offlineLabel => 'Sin conexión...';
@override
String get tryAgainLabel => 'Inténtelo de nuevo';
@override
String membersCountText(int count) {
if (count == 1) return '1 miembro';
return '$count miembros';
}
@override
String watchersCountText(int count) {
if (count == 1) return '1 En línea';
return '$count En línea';
}
@override
String get viewInfoLabel => 'Ver información';
@override
String get leaveGroupLabel => 'Salir del Grupo';
@override
String get leaveLabel => 'SALIR';
@override
String get leaveConversationLabel => 'Salir de la conversación';
@override
String get leaveConversationQuestion =>
'¿Estás seguro de que quiere salir de esta conversación?';
@override
String get showInChatLabel => 'Mostrar en el chat';
@override
String get saveImageLabel => 'Guardar la imagen';
@override
String get saveVideoLabel => 'Guardar el vídeo';
@override
String get uploadErrorLabel => 'ERROR DE TRANSFERENCIA';
@override
String get giphyLabel => 'Giphy';
@override
String get shuffleLabel => 'Mezclar';
@override
String get sendLabel => 'Enviar';
@override
String get withText => 'con';
@override
String get inText => 'en';
@override
String get youText => 'Usted';
@override
String get ofText => 'de';
@override
String get fileText => 'Archivo';
@override
String get replyToMessageLabel => 'Responder al Mensaje';
}
@@ -31,7 +31,7 @@ class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations {
if (users.length == 1) {
return "${first.name} est en train d'écrire";
}
return "${first.name} and ${users.length - 1} sont entrain d'écrire";
return "${first.name} et ${users.length - 1} sont entrain d'écrire";
}
@override
@@ -49,7 +49,7 @@ class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations {
required int remaining,
required int total,
}) =>
'Uploading $remaining/$total ...';
'Transfert en cours $remaining/$total ...';
@override
String pinnedByUserText({
@@ -206,8 +206,8 @@ class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations {
@override
String togglePinUnpinText({required bool pinned}) {
if (pinned) return 'tacher de la conversation';
return 'Attacher à la conversation';
if (pinned) return 'crocher de la conversation';
return 'Épingler à la discussion';
}
@override
@@ -311,7 +311,7 @@ class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations {
String get viewInfoLabel => 'Voir les informations';
@override
String get leaveGroupLabel => 'Quitter le Group';
String get leaveGroupLabel => 'Quitter le Groupe';
@override
String get leaveLabel => 'QUITTER';
@@ -324,7 +324,7 @@ class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations {
'Etes-vous sûr de vouloir quitter cette conversation ?';
@override
String get showInChatLabel => 'Montrer dans le Chat';
String get showInChatLabel => 'Montrer dans la Discussion';
@override
String get saveImageLabel => "Sauvegarder l'image";