Skip to content

Commit

Permalink
Improve localization for various packages (#12473)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zebsterpasha committed Jun 29, 2023
1 parent d2f091a commit 4ccce3e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 15 deletions.
27 changes: 19 additions & 8 deletions packages/core/src/browser/browser-clipboard-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { isFirefox } from './browser';
import { ClipboardService } from './clipboard-service';
import { ILogger } from '../common/logger';
import { MessageService } from '../common/message-service';
import { nls } from '../common/nls';

export interface NavigatorClipboard {
readText(): Promise<string>;
Expand Down Expand Up @@ -52,16 +53,21 @@ export class BrowserClipboardService implements ClipboardService {
} catch (e2) {
this.logger.error('Failed reading clipboard content.', e2);
if (isFirefox) {
this.messageService.warn(`Clipboard API is not available.
It can be enabled by 'dom.events.testing.asyncClipboard' preference on 'about:config' page. Then reload Theia.
Note, it will allow FireFox getting full access to the system clipboard.`);
this.messageService.warn(nls.localize(
'theia/navigator/clipboardWarnFirefox',
// eslint-disable-next-line max-len
"Clipboard API is not available. It can be enabled by '{0}' preference on '{1}' page. Then reload Theia. Note, it will allow FireFox getting full access to the system clipboard.", 'dom.events.testing.asyncClipboard', 'about:config'
));
}
return '';
}
}
if (permission.state === 'denied') {
// most likely, the user intentionally denied the access
this.messageService.warn("Access to the clipboard is denied. Check your browser's permission.");
this.messageService.warn(nls.localize(
'theia/navigator/clipboardWarn',
"Access to the clipboard is denied. Check your browser's permission."
));
return '';
}
return this.getClipboardAPI().readText();
Expand All @@ -80,16 +86,21 @@ export class BrowserClipboardService implements ClipboardService {
} catch (e2) {
this.logger.error('Failed writing to the clipboard.', e2);
if (isFirefox) {
this.messageService.warn(`Clipboard API is not available.
It can be enabled by 'dom.events.testing.asyncClipboard' preference on 'about:config' page. Then reload Theia.
Note, it will allow FireFox getting full access to the system clipboard.`);
this.messageService.warn(nls.localize(
'theia/core/navigator/clipboardWarnFirefox',
// eslint-disable-next-line max-len
"Clipboard API is not available. It can be enabled by '{0}' preference on '{1}' page. Then reload Theia. Note, it will allow FireFox getting full access to the system clipboard.", 'dom.events.testing.asyncClipboard', 'about:config'
));
}
return;
}
}
if (permission.state === 'denied') {
// most likely, the user intentionally denied the access
this.messageService.warn("Access to the clipboard is denied. Check your browser's permission.");
this.messageService.warn(nls.localize(
'theia/core/navigator/clipboardWarn',
"Access to the clipboard is denied. Check your browser's permission."
));
return;
}
return this.getClipboardAPI().writeText(value);
Expand Down
24 changes: 20 additions & 4 deletions packages/git/src/browser/git-scm-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,33 @@ export class GitScmProvider implements ScmProvider {
return DiffUris.encode(
fromFileUri.withScheme(GIT_RESOURCE_SCHEME).withQuery('HEAD'),
changeUri.withScheme(GIT_RESOURCE_SCHEME),
this.labelProvider.getName(changeUri) + ' (Index)');
nls.localize(
'theia/git/tabTitleIndex',
'{0} (Index)',
this.labelProvider.getName(changeUri)
));
}
if (this.stagedChanges.find(c => c.uri === change.uri)) {
return DiffUris.encode(
fromFileUri.withScheme(GIT_RESOURCE_SCHEME),
changeUri,
this.labelProvider.getName(changeUri) + ' (Working tree)');
nls.localize(
'theia/git/tabTitleWorkingTree',
'{0} (Working tree)',
this.labelProvider.getName(changeUri)
));
}
if (this.mergeChanges.find(c => c.uri === change.uri)) {
return changeUri;
}
return DiffUris.encode(
fromFileUri.withScheme(GIT_RESOURCE_SCHEME).withQuery('HEAD'),
changeUri,
this.labelProvider.getName(changeUri) + ' (Working tree)');
nls.localize(
'theia/git/tabTitleWorkingTree',
'{0} (Working tree)',
this.labelProvider.getName(changeUri)
));
}
if (change.staged) {
return changeUri.withScheme(GIT_RESOURCE_SCHEME);
Expand All @@ -264,7 +276,11 @@ export class GitScmProvider implements ScmProvider {
return DiffUris.encode(
changeUri.withScheme(GIT_RESOURCE_SCHEME),
changeUri,
this.labelProvider.getName(changeUri) + ' (Working tree)');
nls.localize(
'theia/git/tabTitleWorkingTree',
'{0} (Working tree)',
this.labelProvider.getName(changeUri)
));
}
return changeUri;
}
Expand Down
8 changes: 5 additions & 3 deletions packages/scm-extra/src/browser/history/scm-history-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,14 @@ export class ScmHistoryWidget extends ScmNavigableListWidget<ScmHistoryListNode>
const repo = this.scmService.findRepository(new URI(this.options.uri));
const repoName = repo ? `${this.labelProvider.getName(new URI(repo.provider.rootUri))}` : '';

const relPathAndRepo = [relPath, repoName].filter(Boolean).join(' in ');
path = ` for ${relPathAndRepo}`;
const relPathAndRepo = [relPath, repoName].filter(Boolean).join(
` ${nls.localize('theia/git/prepositionIn', 'in')} `
);
path = `${relPathAndRepo}`;
}
content = <AlertMessage
type='WARNING'
header={`There is no history available${path}.`}>
header={nls.localize('theia/git/noHistoryForError', 'There is no history available for {0}', `${path}`)}>
{reason}
</AlertMessage>;
break;
Expand Down

0 comments on commit 4ccce3e

Please sign in to comment.