Skip to content

Commit 9ae3672

Browse files
authored
Merge pull request #3 from m-xim/dev
Dev
2 parents 3dae4bd + 25c3203 commit 9ae3672

File tree

10 files changed

+383
-274
lines changed

10 files changed

+383
-274
lines changed

CHANGELOG.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
1-
## [1.1.1](https://github.com/m-xim/fluentus/compare/v1.1.0...v1.1.1) (2025-01-05)
1+
# [1.2.0-dev.4](https://github.com/m-xim/fluentus/compare/v1.2.0-dev.3...v1.2.0-dev.4) (2025-01-09)
2+
3+
4+
### Bug Fixes
5+
6+
* **fluent_api:** replace `fluent.runtime` error handling with ParseError from `fluent.syntax` ([51b2be3](https://github.com/m-xim/fluentus/commit/51b2be3a3ef9014872fa2b36dd24459bcfc498d0))
7+
8+
# [1.2.0-dev.3](https://github.com/m-xim/fluentus/compare/v1.2.0-dev.2...v1.2.0-dev.3) (2025-01-09)
9+
10+
11+
### Bug Fixes
12+
13+
* **fluent_api:** enable uploading of files from subdirectories ([d25ad11](https://github.com/m-xim/fluentus/commit/d25ad11cd54f66dbb4391ee2c10a5998ad2c47f9))
14+
15+
# [1.2.0-dev.2](https://github.com/m-xim/fluentus/compare/v1.2.0-dev.1...v1.2.0-dev.2) (2025-01-09)
216

317

418
### Bug Fixes
519

20+
* **table_manager:** change dict to defaultdict ([4798cdd](https://github.com/m-xim/fluentus/commit/4798cddfdda5e7e5857566dab3da6ed8f39552e1))
21+
22+
# [1.2.0-dev.1](https://github.com/m-xim/fluentus/compare/v1.1.1-dev.3...v1.2.0-dev.1) (2025-01-07)
23+
24+
25+
### Features
26+
27+
* **table:** display all translations in the table ([41e2670](https://github.com/m-xim/fluentus/commit/41e26708bbdc5260984a8dca855b7c565a3676e1))
28+
29+
## [1.1.1-dev.3](https://github.com/m-xim/fluentus/compare/v1.1.1-dev.2...v1.1.1-dev.3) (2025-01-07)
30+
31+
32+
### Bug Fixes
33+
34+
* **api:** ensure translations are properly cleared ([1514859](https://github.com/m-xim/fluentus/commit/1514859fe6b7be5affd08874f85c6159f7b514b6))
635
* **editor:** cursor position ([2f8f078](https://github.com/m-xim/fluentus/commit/2f8f078735e05b9f19ef48df33d0bd3354468b67))
736
* **fluent_api:** fix whitespace (\n,\s,\t,...) characters at end of text, refactor code and add translation types ([9de7e6d](https://github.com/m-xim/fluentus/commit/9de7e6d12889ab43db7d4383599e40b71b67c1fb))
837

38+
## [1.1.1](https://github.com/m-xim/fluentus/compare/v1.1.0...v1.1.1) (2025-01-05)
39+
40+
41+
### Bug Fixes
42+
43+
* **fluent_api:** enable uploading of files from subdirectories ([d25ad11](https://github.com/m-xim/fluentus/commit/d25ad11cd54f66dbb4391ee2c10a5998ad2c47f9))
44+
945
## [1.1.1-dev.2](https://github.com/m-xim/fluentus/compare/v1.1.1-dev.1...v1.1.1-dev.2) (2025-01-05)
1046

1147

README.md

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# fluentus
22
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/m-xim/fluentus)](https://github.com/m-xim/fluentus/releases/latest)
3-
![Deployment Status](https://img.shields.io/github/actions/workflow/status/m-xim/fluentus/release.yml?branch=main&label=build%20main)
4-
![Deployment Status](https://img.shields.io/github/actions/workflow/status/m-xim/fluentus/release.yml?branch=dev&label=build%20dev)
5-
![GitHub License](https://img.shields.io/github/license/m-xim/fluentus)
3+
[![Deployment Status](https://img.shields.io/github/actions/workflow/status/m-xim/fluentus/release.yml?branch=main&label=build%20main)](https://github.com/m-xim/fluentus/actions)
4+
[![Deployment Status](https://img.shields.io/github/actions/workflow/status/m-xim/fluentus/release.yml?branch=dev&label=build%20dev)](https://github.com/m-xim/fluentus/actions)
5+
[![GitHub License](https://img.shields.io/github/license/m-xim/fluentus)](https://github.com/m-xim/fluentus/blob/main/LICENSE)
66

77
[//]: # (## About)
8-
Fluent is a powerful tool designed to edit the Fluent localization files from [Project Fluent](https://projectfluent.org/)
8+
Fluentus is a powerful tool designed to edit the Fluent localization files from [Project Fluent](https://projectfluent.org)
99

1010
> [!WARNING]
1111
> Fluentus is currently in beta stage. Please proceed with caution and ensure to back up your localization files before using Fluentus.
1212
13+
<img src="images/preview.png" alt="Preview Fluentus program" width="600">
14+
1315
## Usage
1416
To run the project, download the latest release from the [Releases](https://github.com/m-xim/fluentus/releases) page. Choose the version for your platform (Windows, macOS, Linux) and run the downloaded file.
1517

1618
<details>
17-
1819
<summary>Run from source</summary>
1920

2021
To run the project from source, follow these steps:
@@ -24,20 +25,34 @@ To run the project from source, follow these steps:
2425
4. Run the project: `python src/app.py`
2526
</details>
2627

27-
## Example Localization Files
28-
Download the `example_locales` folder from the repository. This folder contains the localization files that you can use to test and understand how Fluentus works.
28+
## Localization Files Structure
29+
The localization files are organized into language-specific directories. Each directory contains Fluent Translation List (FTL) files and subdirectories as needed.
30+
31+
```plaintext
32+
locales/
33+
├── en/ # English localization files
34+
│ ├── example.ftl
35+
│ └── subfolder/
36+
│ └── another_example.ftl
37+
├── ru/ # Russian localization files
38+
│ ├── example.ftl
39+
│ └── subfolder/
40+
│ └── another_example.ftl
41+
└── ... # Other language
42+
```
2943

30-
## Contributing
31-
We welcome contributions! To contribute:
32-
1. Fork the repository.
33-
2. Create a new branch:
34-
`git checkout -b feature/your-feature-name`
44+
> [!TIP]
45+
> Download the `example_locales` folder from the repository. This folder contains the localization files that you can use to test and understand how Fluentus works.
46+
47+
## Contributing
48+
We welcome contributions! To contribute:
49+
1. Fork the repository.
50+
2. Create a new branch:
51+
`git checkout -b feature/your-feature-name`
3552
3. Make your changes and submit a pull request.
3653

3754
## Development
38-
3955
<details>
40-
4156
<summary>Building</summary>
4257

4358
To building the project, follow these steps:

images/preview.png

873 KB
Loading

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
PyQt6~=6.8.0
2-
pydantic~=2.10.4
2+
pydantic~=2.10.5
33
fluent.syntax~=0.19.0
44
loguru~=0.7.3

src/config.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@ name = "Fluentus"
88
projects = "projects"
99

1010
[ftl_field]
11-
check = "check"
11+
check = "check"
12+
13+
[table_column]
14+
icon = ""
15+
variable = "Variable"
16+
translation = "Translation"

src/editor.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def __init__(self, folder: Optional[str] = None):
2020
super().__init__()
2121

2222
self.window_editor = None
23-
self.fluent_api = FluentAPI()
23+
self.fluent_api = None
24+
self.table_manager = None
2425

2526
# Load UI
2627
uic.loadUi(resource_path('resource/ui/editor_window.ui'), self)
@@ -45,9 +46,6 @@ def __init__(self, folder: Optional[str] = None):
4546
self.lang_1.activated.connect(self.on_language_changed)
4647
self.lang_2.activated.connect(self.on_language_changed)
4748

48-
# Initialize table manager
49-
self.table_manager = TableManager(self.table, self.fluent_api, self.load_variable)
50-
5149
# Connect save button
5250
self.save_button.clicked.connect(self.save_all_changes)
5351

@@ -64,17 +62,20 @@ def __init__(self, folder: Optional[str] = None):
6462

6563
def on_language_changed(self) -> None:
6664
"""Handle language selection changes."""
67-
# TODO: Instead of creating a new table, update the current ones
68-
self.load_table()
6965
self.load_variable()
7066

7167
def _initialize_folder(self, folder: str) -> None:
7268
"""Initializes the editor with a specified folder."""
73-
self.fluent_api.load_ftl_files(folder)
69+
self.fluent_api = FluentAPI(folder)
70+
71+
# Initialize table manager
72+
self.table_manager = TableManager(self.table, self.fluent_api, self.load_variable)
73+
7474
self.folder_text.setText(folder)
7575
self.refresh_editing_state()
7676
self.set_language_selectors()
77-
self.load_table()
77+
78+
self.table_manager.populate_table()
7879

7980
def save_all_changes(self):
8081
"""Save all changes and notify the user."""
@@ -103,30 +104,16 @@ def set_language_selectors(self):
103104
self.lang_1.setCurrentIndex(0)
104105
self.lang_2.setCurrentIndex(1 if len(languages) >= 2 else 0)
105106

106-
def set_current_item(self):
107-
lang1, lang2 = self.lang_1.currentText(), self.lang_2.currentText()
108-
if not lang1 or not lang2:
109-
return
110-
111-
self.table_manager.set_current_item(lang1, lang2)
112-
113107
def load_table(self):
114108
"""Update the table based on selected languages."""
115-
lang1, lang2 = self.lang_1.currentText(), self.lang_2.currentText()
116-
if not lang1 or not lang2:
117-
return
118109

119-
self.table_manager.populate_table(lang1, lang2)
110+
self.table_manager.populate_table()
120111

121112
def load_variable(self):
122-
variable, attribute = self.table_manager.get_variable()
113+
variable, attribute = self.table_manager.get_selected_names()
123114
if not variable:
124115
return
125116

126-
selected_items = self.table.selectedItems()
127-
if selected_items:
128-
self.table_manager.current_item = selected_items[0]
129-
130117
for editor, field, lang in self.editors:
131118
language = lang.currentText()
132119
data = self.fluent_api.get_translation(variable, language)
@@ -175,14 +162,14 @@ def _open_start_window(self):
175162
def update_cache(self, editor: Union[QPlainTextEdit, QCheckBox], field: str, lang: QComboBox):
176163
"""Update the cache when an editor field is modified."""
177164

178-
variable, attribute = self.table_manager.get_variable()
165+
variable, attribute = self.table_manager.get_selected_names()
179166
if not variable:
180167
return
181168

182169
new_content = editor.toPlainText() if isinstance(editor, QPlainTextEdit) else editor.isChecked()
183170

184171
if self.fluent_api.update(variable, lang.currentText(), field, new_content, attribute):
185-
self.set_current_item()
172+
self.table_manager.set_current_item(lang.currentText())
186173

187174
self.load_variable()
188175

0 commit comments

Comments
 (0)