Skip to content

Commit

Permalink
[FilesTS] Extract i18n / translation functions to separate file
Browse files Browse the repository at this point in the history
Bug: b/289003444
Change-Id: Ib764ae21f98b8fe49e0c1f5bf5ea659d82e9ac54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4969257
Reviewed-by: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Ben Reich <benreich@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1215915}
  • Loading branch information
ben-reich authored and Chromium LUCI CQ committed Oct 27, 2023
1 parent c07ebfa commit 9b2cfae
Show file tree
Hide file tree
Showing 80 changed files with 597 additions and 639 deletions.
4 changes: 4 additions & 0 deletions chrome/browser/ash/file_manager/file_manager_jstest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, ThumbnailModel) {
RunTestURL("foreground/js/metadata/thumbnail_model_unittest.js");
}

IN_PROC_BROWSER_TEST_F(FileManagerJsTest, TranslationsTest) {
RunTestURL("common/js/translations_unittest.js");
}

IN_PROC_BROWSER_TEST_F(FileManagerJsTest, UtilTest) {
RunTestURL("common/js/util_unittest.js");
}
Expand Down
2 changes: 0 additions & 2 deletions ui/file_manager/file_manager/background/js/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ js_library("mock_volume_manager") {
deps = [
"//ash/webui/common/resources:assert",
"//ui/file_manager/file_manager/common/js:mock_entry",
"//ui/file_manager/file_manager/common/js:util",
"//ui/file_manager/file_manager/common/js:volume_manager_types",
"//ui/file_manager/file_manager/externs:entry_location",
"//ui/file_manager/file_manager/externs:files_app_entry_interfaces",
Expand All @@ -119,7 +118,6 @@ js_library("progress_center") {
"//ui/file_manager/file_manager/common/js:async_util",
"//ui/file_manager/file_manager/common/js:progress_center_common",
"//ui/file_manager/file_manager/common/js:url_constants",
"//ui/file_manager/file_manager/common/js:util",
"//ui/file_manager/file_manager/externs:progress_center_panel",
"//ui/file_manager/file_manager/externs/background:progress_center",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import {AsyncQueue, RateLimiter} from '../../common/js/async_util.js';
import {unwrapEntry, urlToEntry} from '../../common/js/entry_utils.js';
import {isInlineSyncStatusEnabled} from '../../common/js/flags.js';
import {ProgressCenterItem, ProgressItemState, ProgressItemType} from '../../common/js/progress_center_common.js';
import {str, strf} from '../../common/js/translations.js';
import {toFilesAppURL} from '../../common/js/url_constants.js';
import {str, strf, util} from '../../common/js/util.js';
import {util} from '../../common/js/util.js';
import {ProgressCenter} from '../../externs/background/progress_center.js';
import {MetadataModelInterface} from '../../externs/metadata_model.js';
import {getStore} from '../../state/store.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import {startIOTask} from '../../common/js/api.js';
import {PolicyErrorType, ProgressCenterItem, ProgressItemState, ProgressItemType} from '../../common/js/progress_center_common.js';
import {str, strf, util} from '../../common/js/util.js';
import {getFileErrorString, str, strf} from '../../common/js/translations.js';
import {util} from '../../common/js/util.js';
import {VolumeManagerCommon} from '../../common/js/volume_manager_types.js';
import {ProgressCenter} from '../../externs/background/progress_center.js';
import {getStore} from '../../state/store.js';
Expand Down Expand Up @@ -226,7 +227,7 @@ function getMessageFromProgressEvent(
return str('DELETE_IN_USE_ERROR');
}
}
const detail = util.getFileErrorString(event.errorName);
const detail = getFileErrorString(event.errorName);
switch (event.type) {
case chrome.fileManagerPrivate.IOTaskType.COPY:
return strf('COPY_FILESYSTEM_ERROR', detail);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {assert} from 'chrome://resources/ash/common/assert.js';

import {isComputersRoot, isFakeEntry, isSameEntry, isTeamDriveRoot} from '../../common/js/entry_utils.js';
import {MockEntry, MockFileSystem} from '../../common/js/mock_entry.js';
import {str} from '../../common/js/util.js';
import {str} from '../../common/js/translations.js';
import {VolumeManagerCommon} from '../../common/js/volume_manager_types.js';
import {EntryLocation} from '../../externs/entry_location.js';
import {FakeEntry, FilesAppEntry} from '../../externs/files_app_entry_interfaces.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import {AsyncQueue} from '../../common/js/async_util.js';
import {notifications} from '../../common/js/notifications.js';
import {ProgressCenterItem, ProgressItemState, ProgressItemType} from '../../common/js/progress_center_common.js';
import {str} from '../../common/js/translations.js';
import {getFilesAppIconURL} from '../../common/js/url_constants.js';
import {str} from '../../common/js/util.js';
import {ProgressCenter} from '../../externs/background/progress_center.js';
import {ProgressCenterPanelInterface} from '../../externs/progress_center_panel.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {assert} from 'chrome://resources/ash/common/assert.js';

import {FakeEntryImpl} from '../../common/js/files_app_entry_types.js';
import {isDriveFsBulkPinningEnabled} from '../../common/js/flags.js';
import {str} from '../../common/js/util.js';
import {str} from '../../common/js/translations.js';
import {VolumeManagerCommon} from '../../common/js/volume_manager_types.js';
import {FakeEntry, FilesAppEntry} from '../../externs/files_app_entry_interfaces.js';
import type {VolumeInfo} from '../../externs/volume_info.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {str, util} from '../../common/js/util.js';
import {str} from '../../common/js/translations.js';
import {util} from '../../common/js/util.js';
import {VolumeManagerCommon} from '../../common/js/volume_manager_types.js';
import {addVolume} from '../../state/ducks/volumes.js';
import {getStore} from '../../state/store.js';
Expand Down
1 change: 0 additions & 1 deletion ui/file_manager/file_manager/common/js/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ js_library("progress_center_common") {

js_library("recent_date_bucket") {
deps = [
":util",
"//ui/file_manager/file_manager/externs:file_manager_private",
"//ui/file_manager/file_manager/externs/ts:state",
]
Expand Down
10 changes: 5 additions & 5 deletions ui/file_manager/file_manager/common/js/entry_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {getStore} from '../../state/store.js';
import {createDOMError} from './dom_utils.js';
import {EntryList, FakeEntryImpl, VolumeEntry} from './files_app_entry_types.js';
import {isArcVmEnabled, isPluginVmEnabled} from './flags.js';
import {collator, getEntryLabel} from './translations.js';
import {util} from './util.js';
import {VolumeManagerCommon} from './volume_manager_types.js';

Expand Down Expand Up @@ -466,7 +467,7 @@ export function isDescendantEntry(
*/
export function compareName(
entry1: Entry|FilesAppEntry, entry2: Entry|FilesAppEntry) {
return util.collator.compare(entry1.name, entry2.name);
return collator.compare(entry1.name, entry2.name);
}

/**
Expand All @@ -475,17 +476,16 @@ export function compareName(
export function compareLabel(
locationInfo: EntryLocation, entry1: Entry|FilesAppEntry,
entry2: Entry|FilesAppEntry) {
return util.collator.compare(
util.getEntryLabel(locationInfo, entry1),
util.getEntryLabel(locationInfo, entry2));
return collator.compare(
getEntryLabel(locationInfo, entry1), getEntryLabel(locationInfo, entry2));
}

/**
* Compare by path.
*/
export function comparePath(
entry1: Entry|FilesAppEntry, entry2: Entry|FilesAppEntry) {
return util.collator.compare(entry1.fullPath, entry2.fullPath);
return collator.compare(entry1.fullPath, entry2.fullPath);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ui/file_manager/file_manager/common/js/file_tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {FileData} from '../../externs/ts/state.js';
import {TaskHistory} from '../../foreground/js/task_history.js';

import {FileType} from './file_type.js';
import {str} from './translations.js';
import {LEGACY_FILES_EXTENSION_ID, SWA_APP_ID, SWA_FILES_APP_URL, toFilesAppURL} from './url_constants.js';
import {str} from './util.js';

export interface AnnotatedTask extends chrome.fileManagerPrivate.FileTask {
iconType: string;
Expand Down
4 changes: 2 additions & 2 deletions ui/file_manager/file_manager/common/js/recent_date_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import {SearchRecency} from '../../externs/ts/state.js';

import {util} from './util.js';
import {getLocaleBasedWeekStart} from './translations.js';

/**
* Given a date and now date, return the date bucket it belongs to.
Expand All @@ -32,7 +32,7 @@ export function getRecentDateBucket(date, now) {
return chrome.fileManagerPrivate.RecentDateBucket.YESTERDAY;
}
const startOfThisWeek = new Date(startOfToday);
const localeBasedWeekStart = util.getLocaleBasedWeekStart();
const localeBasedWeekStart = getLocaleBasedWeekStart();
const daysDiff = (startOfToday.getDay() - localeBasedWeekStart + 7) % 7;
startOfThisWeek.setDate(startOfToday.getDate() - daysDiff);
if (date >= startOfThisWeek) {
Expand Down

0 comments on commit 9b2cfae

Please sign in to comment.