Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit dc241e4

Browse files
committed
new translations
1 parent 19aeb68 commit dc241e4

File tree

6 files changed

+24
-42
lines changed

6 files changed

+24
-42
lines changed

src/components/portals/DataviewFiltersPortal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import ReactDOM from "react-dom";
1818
import { usePopper } from "react-popper";
1919
import { Notice } from "obsidian";
2020
import MenuUpIcon from "components/img/MenuUpIcon";
21+
import { t } from "lang/helpers";
2122

2223
const DataviewFiltersPortal = (props: DataviewFiltersProps) => {
2324
const { table } = props;
@@ -150,7 +151,7 @@ const DataviewFiltersPortal = (props: DataviewFiltersProps) => {
150151
value={key}
151152
key={`MenuItem-OperatorSelector-${value[0]}-${selectorProps.index}`}
152153
>
153-
{value[1]}
154+
{t(value[1] as any)}
154155
</MenuItem>
155156
);
156157
})}

src/helpers/Constants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,11 @@ export const OperatorFilter = Object.freeze({
294294
LESS_THAN: ['LESS_THAN', '<'],
295295
GREATER_THAN_OR_EQUAL: ['GREATER_THAN_OR_EQUAL', '>='],
296296
LESS_THAN_OR_EQUAL: ['LESS_THAN_OR_EQUAL', '<='],
297-
CONTAINS: ['CONTAINS', 'contains'],
298-
STARTS_WITH: ['STARTS_WITH', 'starts with'],
299-
ENDS_WITH: ['ENDS_WITH', 'ends with'],
300-
IS_EMPTY: ['IS_EMPTY', 'is empty'],
301-
IS_NOT_EMPTY: ['IS_NOT_EMPTY', 'is not empty'],
297+
CONTAINS: ['CONTAINS', 'operator_contains'],
298+
STARTS_WITH: ['STARTS_WITH', 'operator_starts_with'],
299+
ENDS_WITH: ['ENDS_WITH', 'operator_ends_with'],
300+
IS_EMPTY: ['IS_EMPTY', 'operator_is_empty'],
301+
IS_NOT_EMPTY: ['IS_NOT_EMPTY', 'operator_is_not_empty'],
302302
});
303303

304304
export function getOperatorFilterValue(keyToFind: string): string {

src/helpers/VaultManagement.ts

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -180,29 +180,12 @@ export async function updateRowFileProxy(file: TFile, columnId: string, newValue
180180
export async function updateRowFile(file: TFile, columnId: string, newValue: Literal, columns: TableColumn[], ddbbConfig: LocalSettings, option: string): Promise<void> {
181181
LOGGER.info(`=>updateRowFile. file: ${file.path} | columnId: ${columnId} | newValue: ${newValue} | option: ${option}`);
182182
const content = await VaultManagerDB.obtainContentFromTfile(file);
183+
const contentHasFrontmatter = hasFrontmatter(content);
183184
const frontmatterKeys = VaultManagerDB.obtainFrontmatterKeys(content);
184185
const rowFields = obtainRowDatabaseFields(file, columns, frontmatterKeys);
185186
const column = columns.find(
186187
c => c.key === (UpdateRowOptions.COLUMN_KEY === option ? newValue : columnId)
187188
);
188-
189-
// Adds an empty frontmatter at the beginning of the file
190-
async function addFrontmatter(): Promise<void> {
191-
/* Regex explanation
192-
* group 1 all content
193-
*/
194-
const frontmatterRegex = /(^[\s\S]*$)/g;
195-
196-
197-
const noteObject = {
198-
action: 'replace',
199-
file: file,
200-
regexp: frontmatterRegex,
201-
newValue: `---\n---\n$1`
202-
};
203-
// update content on disk and in memory
204-
await VaultManagerDB.editNoteContent(noteObject);
205-
}
206189
/*******************************************************************************************
207190
* FRONTMATTER GROUP FUNCTIONS
208191
*******************************************************************************************/
@@ -248,15 +231,18 @@ export async function updateRowFile(file: TFile, columnId: string, newValue: Lit
248231
}
249232

250233
async function persistFrontmatter(deletedColumn?: string): Promise<void> {
251-
const frontmatterGroupRegex = /^---[\s\S]+?---/g;
252-
const frontmatterFieldsText = parseFrontmatterFieldsToString(rowFields, ddbbConfig, deletedColumn);
253-
const noteObject = {
254-
action: 'replace',
255-
file: file,
256-
regexp: frontmatterGroupRegex,
257-
newValue: `${frontmatterFieldsText}`
258-
};
259-
await VaultManagerDB.editNoteContent(noteObject);
234+
// If the frontmatter is empty, do not persist it
235+
if (Object.keys(rowFields.frontmatter).length > 0) {
236+
const frontmatterGroupRegex = contentHasFrontmatter ? /^---[\s\S]+?---/g : /(^[\s\S]*$)/g;
237+
const frontmatterFieldsText = parseFrontmatterFieldsToString(rowFields, ddbbConfig, deletedColumn);
238+
const noteObject = {
239+
action: 'replace',
240+
file: file,
241+
regexp: frontmatterGroupRegex,
242+
newValue: contentHasFrontmatter ? `${frontmatterFieldsText}` : `${frontmatterFieldsText}\n$1`,
243+
};
244+
await VaultManagerDB.editNoteContent(noteObject);
245+
}
260246
}
261247

262248
/*******************************************************************************************
@@ -340,11 +326,6 @@ export async function updateRowFile(file: TFile, columnId: string, newValue: Lit
340326
updateOptions[UpdateRowOptions.INLINE_VALUE] = inlineColumnEdit;
341327
// Execute action
342328
if (updateOptions[option]) {
343-
// Check if file has frontmatter
344-
if (!hasFrontmatter(content)) {
345-
// If not, add it
346-
await addFrontmatter();
347-
}
348329
// Then execute the action
349330
await updateOptions[option]();
350331
} else {

src/lang/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ export function t(str: keyof typeof en): string {
5959
LOGGER.error('Error: database locale not found', lang);
6060
}
6161

62-
return (locale && locale[str]) || en[str];
62+
return (locale && locale[str]) || en[str] || str;
6363
}

src/lang/locale/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ export default {
1212
'operator_ends_with': 'Ends with',
1313
'operator_is_empty': 'Is empty',
1414
'operator_is_not_empty': 'Is not empty',
15-
};
15+
};

src/lang/locale/es.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
/** OPERATOR FILTERS */
1010
'operator_contains': 'Contiene',
1111
'operator_starts_with': 'Comienza con',
12-
'operator_ends_with': 'Ends with',
12+
'operator_ends_with': 'Termina con',
1313
'operator_is_empty': 'Está vacío',
1414
'operator_is_not_empty': 'No está vacío',
15-
};
15+
};

0 commit comments

Comments
 (0)