MOBILE-3142 chat: Translate said to string

main
Pau Ferrer Ocaña 2019-09-10 16:40:53 +02:00
parent 0dd869d59e
commit 273d88262c
6 changed files with 26 additions and 3 deletions

View File

@ -433,14 +433,17 @@
"addon.mod_chat.errorwhilegettingchatusers": "local_moodlemobileapp",
"addon.mod_chat.errorwhileretrievingmessages": "local_moodlemobileapp",
"addon.mod_chat.errorwhilesendingmessage": "local_moodlemobileapp",
"addon.mod_chat.messagebeepseveryone": "chat",
"addon.mod_chat.messagebeepsyou": "chat",
"addon.mod_chat.messageenter": "chat",
"addon.mod_chat.messageexit": "chat",
"addon.mod_chat.messages": "chat",
"addon.mod_chat.messageyoubeep": "chat",
"addon.mod_chat.modulenameplural": "chat",
"addon.mod_chat.mustbeonlinetosendmessages": "local_moodlemobileapp",
"addon.mod_chat.nomessages": "chat",
"addon.mod_chat.nosessionsfound": "local_moodlemobileapp",
"addon.mod_chat.saidto": "chat",
"addon.mod_chat.send": "chat",
"addon.mod_chat.sessionstart": "chat",
"addon.mod_chat.showincompletesessions": "local_moodlemobileapp",

View File

@ -19,6 +19,7 @@
"mustbeonlinetosendmessages": "You must be online to send messages.",
"nomessages": "No messages yet",
"nosessionsfound": "No sessions found",
"saidto": "said to",
"send": "Send",
"sessionstart": "The next chat session will start on {{$a.date}}, ({{$a.fromnow}} from now)",
"showincompletesessions": "Show incomplete sessions",

View File

@ -69,7 +69,7 @@
<ion-footer color="light" class="footer-adjustable">
<ion-toolbar color="light" position="bottom">
<p text-center *ngIf="!isOnline">{{ 'addon.mod_chat.mustbeonlinetosendmessages' | translate }}</p>
<core-send-message-form [sendDisabled]="sending" *ngIf="isOnline && polling && loaded" [message]="newMessage" (onSubmit)="sendMessage($event)" [showKeyboard]="showKeyboard" [placeholder]="'addon.messages.newmessage' | translate" (onResize)="resizeContent()"></core-send-message-form>
<core-send-message-form [sendDisabled]="sending" *ngIf="isOnline && polling && loaded" [message]="newMessage" (onSubmit)="sendMessage($event)" [placeholder]="'addon.messages.newmessage' | translate" (onResize)="resizeContent()"></core-send-message-form>
<button *ngIf="isOnline && !polling && loaded" (click)="reconnect()" ion-button block color="light">{{ 'core.login.reconnect' | translate }}</button>
</ion-toolbar>
</ion-footer>

View File

@ -133,7 +133,7 @@ export class AddonModChatChatPage {
modal.onDidDismiss((data) => {
if (data && data.talkTo) {
this.newMessage = `To ${data.talkTo}: ` + this.sendMessageForm.message;
this.newMessage = `To ${data.talkTo}: ` + (this.sendMessageForm.message || '');
}
if (data && data.beepTo) {
this.sendMessage('', data.beepTo);

View File

@ -13,6 +13,8 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreTextUtilsProvider } from '@providers/utils/text';
import * as moment from 'moment';
import AddonModChatMessageWithUserData from './chat';
@ -22,6 +24,13 @@ import AddonModChatMessageWithUserData from './chat';
@Injectable()
export class AddonModChatHelperProvider {
static patternto = new RegExp(/^To\s([^:]+):(.*)/);
constructor(protected translate: TranslateService,
protected textUtils: CoreTextUtilsProvider) {
}
/**
* Give some format info about messages.
*
@ -30,7 +39,10 @@ export class AddonModChatHelperProvider {
* @param prevMessage Previous Message in a discussion (if any).
* @return Message with additional info.
*/
formatMessage(currentUserId: number, message: AddonModChatMessageWithUserData, prevMessage?: any): any {
formatMessage(currentUserId: number, message: AddonModChatMessageWithUserData,
prevMessage?: AddonModChatMessageWithUserData): any {
message.message = message.message.trim();
message.showDate = this.showDate(message, prevMessage);
message.beep = message.message.substr(0, 5) == 'beep ' && message.message.substr(5).trim();
@ -41,6 +53,12 @@ export class AddonModChatHelperProvider {
message.message = message.message.substr(4).trim();
}
if (!message.special && message.message.match(AddonModChatHelperProvider.patternto)) {
const matches = message.message.match(AddonModChatHelperProvider.patternto);
message.message = '<b>' + this.translate.instant('addon.mod_chat.saidto') +
'</b> <i>' + matches[1] + '</i>: ' + matches[2];
}
message.showUserData = this.showUserData(currentUserId, message, prevMessage);
prevMessage ?
prevMessage.showTail = this.showTail(prevMessage, message) : null;

View File

@ -442,6 +442,7 @@
"addon.mod_chat.mustbeonlinetosendmessages": "You must be online to send messages.",
"addon.mod_chat.nomessages": "No messages yet",
"addon.mod_chat.nosessionsfound": "No sessions found",
"addon.mod_chat.saidto": "said to",
"addon.mod_chat.send": "Send",
"addon.mod_chat.sessionstart": "The next chat session will start on {{$a.date}}, ({{$a.fromnow}} from now)",
"addon.mod_chat.showincompletesessions": "Show incomplete sessions",