Skip to content

Commit

Permalink
Localization support
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Mar 12, 2024
1 parent d9fa027 commit 7d2be2a
Show file tree
Hide file tree
Showing 64 changed files with 612 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class HTMLPerspectiveViewerDatagridToolbarElement extends HTMLElement {
</style>
<div id="toolbar">
<span id="scroll_lock" class="button">
<span>Free Scroll</span>
<span></span>
</span>
<span id="edit_mode" class="button"><span>Read Only</span></span>
<span id="edit_mode" class="button"><span></span></span>
</div>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class FormatterCache {
options.timeStyle = type_config.format.timeStyle;
}

return new Intl.DateTimeFormat([], options);
return new Intl.DateTimeFormat(navigator.languages, options);
} else {
const options = {
// ...type_config.format,
Expand Down Expand Up @@ -112,7 +112,7 @@ export class FormatterCache {
options.hour12 = true;
}

return new Intl.DateTimeFormat([], options);
return new Intl.DateTimeFormat(navigator.languages, options);
}
} else {
const options = {
Expand All @@ -126,7 +126,7 @@ export class FormatterCache {
options.dateStyle = type_config.format.dateStyle;
}

return new Intl.DateTimeFormat([], options);
return new Intl.DateTimeFormat(navigator.languages, options);
}
}

Expand All @@ -136,7 +136,7 @@ export class FormatterCache {
format = plugin.number_format;
}

return new FORMATTER_CONS[type]([], format);
return new FORMATTER_CONS[type](navigator.languages, format);
}

create_boolean_formatter(type, plugin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function createDataListener(viewer) {
);
metadata.push(column);
if (is_settings_open) {
path_parts.push("Edit");
path_parts.push("");
}

column_headers.push(path_parts);
Expand Down
10 changes: 0 additions & 10 deletions packages/perspective-viewer-datagrid/src/js/model/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ export function toggle_edit_mode(force = undefined) {
this.classList.toggle("editable", force);
if (this._edit_mode !== undefined) {
this._edit_mode.classList.toggle("editable", force);
if (force) {
this._edit_mode.children[0].textContent = "Editable";
} else {
this._edit_mode.children[0].textContent = "Read Only";
}
}
}

Expand All @@ -36,10 +31,5 @@ export function toggle_scroll_lock(force = undefined) {
this.classList.toggle("sub-cell-scroll-disabled", force);
if (this._scroll_lock !== undefined) {
this._scroll_lock.classList.toggle("lock-scroll", force);
if (!force) {
this._scroll_lock.children[0].textContent = "Free Scroll";
} else {
this._scroll_lock.children[0].textContent = "Align Scroll";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,18 @@ regular-table table {
content: none;
}
}

regular-table
#psp-column-edit-buttons
th:not(.rt-group-corner)
span:not(.rt-column-resize):before {
content: var(--datagrid-column-edit-button--content, "Edit");
}

perspective-viewer:not([settings]) {
@include design-slash-architecture-bug;
}

:host-context(perspective-viewer:not([settings])) {
@include design-slash-architecture-bug;
}
Expand Down
30 changes: 23 additions & 7 deletions packages/perspective-viewer-datagrid/src/less/toolbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@
-webkit-mask-image: var(--toolbar-edit-mode-active--content);
}

#edit_mode span:before {
content: var(--edit-mode-toggle--content, "Read Only");
}

#edit_mode.editable span:before {
content: var(--edit-mode-alt-toggle--content, "Editable");
}

#scroll_lock span:before {
content: var(--scroll-lock-toggle--content, "Free Scroll");
}

#scroll_lock.lock-scroll span:before {
content: var(--scroll-lock-alt-toggle--content, "Align Scroll");
}

:host(.aggregated) #toolbar #edit_mode {
display: none;
}
Expand All @@ -78,15 +94,16 @@
}

.button {
display: inline-flex;
align-items: center;
user-select: none;
width: 37px;
height: 22px;
border-radius: 3px;
border: 1px solid transparent;
box-sizing: border-box;
display: inline-flex;
font-size: var(--label--font-size, 0.75em);
height: 22px;
user-select: none;
white-space: nowrap;
border: 1px solid transparent;
border-radius: 3px;
width: 37px;
}

.button > span {
Expand All @@ -112,6 +129,5 @@

.button:hover > span {
display: contents;
font-size: 9px;
line-height: 36px;
}
6 changes: 3 additions & 3 deletions packages/perspective/src/js/perspective.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ const DEFAULT_ASSETS = [
];

const CONTENT_TYPES = {
".js": "text/javascript",
".css": "text/css",
".json": "application/json",
".js": "text/javascript; charset=utf-8",
".css": "text/css; charset=utf-8",
".json": "application/json; charset=utf-8",
".arrow": "arraybuffer",
".feather": "arraybuffer",
".wasm": "application/wasm",
Expand Down
17 changes: 0 additions & 17 deletions rust/perspective-viewer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions rust/perspective-viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ js-sys = "0.3.64"
# Parse ExprTK for syntax highlighting.
nom = "7.1.1"

# Comma-sep numeric representation
num-format = "0.4.4"

# MessagePack serialization
rmp-serde = "1.1.1"

Expand Down
1 change: 1 addition & 0 deletions rust/perspective-viewer/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fn main() -> Result<(), anyhow::Error> {
if !cfg!(feature = "define_custom_elements_async") {
build.add_file("variables.less");
build.add_file("icons.less");
build.add_file("intl.less");
build.add_file("pro.less");
build.add_file("pro-dark.less");
build.add_file("monokai.less");
Expand Down
6 changes: 5 additions & 1 deletion rust/perspective-viewer/src/less/column-dropdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
position: fixed;
z-index: 10000;
outline: none;
font-size: 12px;
font-size: 0.75em;
border: inherit;
// box-shadow: 0 2px 4px 0 rgb(0 0 0 / 10%);
user-select: none;
Expand Down Expand Up @@ -56,6 +56,10 @@
font-size: 8px;
}

.no-results:before {
content: var(--no-results--content, "Invalid Column");
}

#add-expression {
&:before {
@include icon;
Expand Down
39 changes: 32 additions & 7 deletions rust/perspective-viewer/src/less/column-selector.less
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
}

:host {
#add-expression-button:before {
content: var(--add-expression-button--content, "New Column");
}

.column-selector-column-title {
display: flex;
width: 100%;
Expand Down Expand Up @@ -80,7 +84,6 @@
border: var(--column-add--border, 1px solid transparent);
min-height: 24px;
flex-direction: row;
font-size: 12px;
background-color: #8b868045;
border-radius: 2px;
display: flex;
Expand Down Expand Up @@ -184,7 +187,6 @@
display: flex;
flex-direction: row-reverse;
align-items: center;
font-size: 12px;

// Expression column toolbar buttons
span.expression-edit-button,
Expand Down Expand Up @@ -233,7 +235,6 @@
cursor: move;
display: flex;
align-items: start;
font-size: 12px;
flex-grow: 1;
color: inherit;
box-sizing: border-box;
Expand Down Expand Up @@ -315,12 +316,12 @@
}

#sub-columns:before {
font-size: 9px;
font-size: var(--label--font-size, 0.75em);
padding: var(--column_type--padding, 0px 0px 0px 0px);
position: absolute;
margin-top: 14px;
top: 0;
content: "All Columns";
content: var(--all-columns-label--content, "All Columns");
}

#sub-columns #add-expression {
Expand Down Expand Up @@ -393,6 +394,30 @@
}
}

// .column-selector-column[data-index="0"]:before {
// content: var(--column-selector-column-0--label, attr(data-label));
// }

// .column-selector-column[data-index="1"]:before {
// content: var(--column-selector-column-1--label, attr(data-label));
// }

// .column-selector-column[data-index="2"]:before {
// content: var(--column-selector-column-2--label, attr(data-label));
// }

// .column-selector-column[data-index="3"]:before {
// content: var(--column-selector-column-3--label, attr(data-label));
// }

// .column-selector-column[data-index="4"]:before {
// content: var(--column-selector-column-4--label, attr(data-label));
// }

// .column-selector-column[data-index="5"]:before {
// content: var(--column-selector-column-5--label, attr(data-label));
// }

.column-selector-column {
position: relative;

Expand All @@ -406,12 +431,12 @@
}

&:before {
font-size: 9px;
font-size: var(--label--font-size, 0.75em);
left: 0px;
padding: var(--column_type--padding, 0px 0px 0px 0px);
position: absolute;
margin-top: -43px;
content: attr(data-label);
content: var(--default-column-title, attr(data-label));
}

&[data-label] {
Expand Down
Loading

0 comments on commit 7d2be2a

Please sign in to comment.