dars-framework 1.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. dars/__init__.py +0 -0
  2. dars/all.py +69 -0
  3. dars/cli/__init__.py +0 -0
  4. dars/cli/doctor/__init__.py +1 -0
  5. dars/cli/doctor/detect.py +154 -0
  6. dars/cli/doctor/doctor.py +176 -0
  7. dars/cli/doctor/installers.py +100 -0
  8. dars/cli/doctor/persist.py +62 -0
  9. dars/cli/doctor/preflight.py +33 -0
  10. dars/cli/doctor/ui.py +54 -0
  11. dars/cli/hot_reload.py +33 -0
  12. dars/cli/main.py +1107 -0
  13. dars/cli/preview.py +448 -0
  14. dars/cli/translations.py +531 -0
  15. dars/components/__init__.py +0 -0
  16. dars/components/advanced/__init__.py +8 -0
  17. dars/components/advanced/accordion.py +26 -0
  18. dars/components/advanced/card.py +33 -0
  19. dars/components/advanced/modal.py +45 -0
  20. dars/components/advanced/navbar.py +44 -0
  21. dars/components/advanced/table.py +25 -0
  22. dars/components/advanced/tabs.py +31 -0
  23. dars/components/basic/__init__.py +34 -0
  24. dars/components/basic/button.py +55 -0
  25. dars/components/basic/checkbox.py +35 -0
  26. dars/components/basic/container.py +29 -0
  27. dars/components/basic/datepicker.py +139 -0
  28. dars/components/basic/image.py +36 -0
  29. dars/components/basic/input.py +57 -0
  30. dars/components/basic/link.py +31 -0
  31. dars/components/basic/markdown.py +86 -0
  32. dars/components/basic/page.py +20 -0
  33. dars/components/basic/progressbar.py +18 -0
  34. dars/components/basic/radiobutton.py +35 -0
  35. dars/components/basic/select.py +82 -0
  36. dars/components/basic/slider.py +63 -0
  37. dars/components/basic/spinner.py +12 -0
  38. dars/components/basic/text.py +23 -0
  39. dars/components/basic/textarea.py +46 -0
  40. dars/components/basic/tooltip.py +19 -0
  41. dars/components/layout/__init__.py +0 -0
  42. dars/components/layout/anchor.py +13 -0
  43. dars/components/layout/flex.py +26 -0
  44. dars/components/layout/grid.py +45 -0
  45. dars/config.py +134 -0
  46. dars/core/__init__.py +0 -0
  47. dars/core/app.py +957 -0
  48. dars/core/component.py +284 -0
  49. dars/core/events.py +102 -0
  50. dars/core/js_bridge.py +99 -0
  51. dars/core/properties.py +127 -0
  52. dars/core/state.py +309 -0
  53. dars/dars_tests/apps_test/health_check.py +56 -0
  54. dars/dars_tests/run_tests.py +275 -0
  55. dars/dars_tests/tests/test_advanced_components.py +69 -0
  56. dars/dars_tests/tests/test_basic_components.py +88 -0
  57. dars/dars_tests/tests/test_core_and_cli.py +17 -0
  58. dars/dars_tests/tests/test_layout_components.py +58 -0
  59. dars/dars_tests/tests/test_version_check.py +21 -0
  60. dars/docs/__init__.py +0 -0
  61. dars/docs/app.md +290 -0
  62. dars/docs/cli.md +80 -0
  63. dars/docs/components.md +1679 -0
  64. dars/docs/custom_components.md +30 -0
  65. dars/docs/events.md +45 -0
  66. dars/docs/exporters.md +162 -0
  67. dars/docs/getting_started.md +79 -0
  68. dars/docs/index.md +18 -0
  69. dars/docs/scripts.md +593 -0
  70. dars/docs/state_management.md +57 -0
  71. dars/exporters/__init__.py +0 -0
  72. dars/exporters/base.py +96 -0
  73. dars/exporters/web/OLD/html_css_js_OLD4.py +1538 -0
  74. dars/exporters/web/OLD/html_css_js_old.py +1406 -0
  75. dars/exporters/web/OLD/html_css_js_old2.py +1406 -0
  76. dars/exporters/web/__init__.py +0 -0
  77. dars/exporters/web/html_css_js.py +2675 -0
  78. dars/exporters/web/vdom.py +251 -0
  79. dars/js_lib.py +206 -0
  80. dars/scripts/__init__.py +0 -0
  81. dars/scripts/dscript.py +26 -0
  82. dars/scripts/script.py +39 -0
  83. dars/security.py +195 -0
  84. dars/templates/__init__.py +0 -0
  85. dars/templates/__pycache__/__init__.cpython-311.pyc +0 -0
  86. dars/templates/examples/README.md +4 -0
  87. dars/templates/examples/__pycache__/dynamic_event_demo.cpython-311.pyc +0 -0
  88. dars/templates/examples/advanced/Modal_Demo/advanced_modal_demo.py +275 -0
  89. dars/templates/examples/advanced/SimpleDashboard/dashboard.py +437 -0
  90. dars/templates/examples/advanced/SimpleModermWeb/modern_web_app.py +452 -0
  91. dars/templates/examples/advanced/VariousComponents/all_components_demo.py +87 -0
  92. dars/templates/examples/advanced/__init__.py +0 -0
  93. dars/templates/examples/advanced/dState/state_mods_demo.py +68 -0
  94. dars/templates/examples/basic/Forms/form_components.py +516 -0
  95. dars/templates/examples/basic/Forms/simple_form.py +379 -0
  96. dars/templates/examples/basic/HelloWorld/hello_world.py +56 -0
  97. dars/templates/examples/basic/Layouts/flex_layout_responsive.py +13 -0
  98. dars/templates/examples/basic/Layouts/grid_layout_responsive.py +12 -0
  99. dars/templates/examples/basic/Layouts/layout_multipage_demo.py +23 -0
  100. dars/templates/examples/basic/Multipage/multipage_example.py +67 -0
  101. dars/templates/examples/basic/PWA/icon-192x192.png +0 -0
  102. dars/templates/examples/basic/PWA/icon-512x512.png +0 -0
  103. dars/templates/examples/basic/PWA/pwa_custom_icons.py +33 -0
  104. dars/templates/examples/basic/__init__.py +0 -0
  105. dars/templates/examples/demo/__pycache__/complete_app.cpython-311.pyc +0 -0
  106. dars/templates/examples/demo/complete_app.py +21 -0
  107. dars/templates/examples/markdown/MarkdownTemplate/README.md +159 -0
  108. dars/templates/examples/markdown/MarkdownTemplate/markdown_template.py +21 -0
  109. dars/templates/examples/markdown/MarkdownTemplate/other_docs.md +1 -0
  110. dars/templates/examples/markdown/__init__.py +0 -0
  111. dars/templates/html/__init__.py +0 -0
  112. dars/version.py +2 -0
  113. dars_framework-1.2.3.dist-info/METADATA +15 -0
  114. dars_framework-1.2.3.dist-info/RECORD +118 -0
  115. dars_framework-1.2.3.dist-info/WHEEL +5 -0
  116. dars_framework-1.2.3.dist-info/entry_points.txt +2 -0
  117. dars_framework-1.2.3.dist-info/licenses/LICENSE +21 -0
  118. dars_framework-1.2.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,531 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Dars Translations - Translation system for Dars CLI
4
+ """
5
+
6
+ # Diccionario de traducciones
7
+ translations = {
8
+ 'en': {
9
+ # CLI descriptions
10
+ 'cli_description': "Dars Exporter - Export Dars applications to Web",
11
+ 'cli_subtitle': "Multiplatform UI Framework in Python",
12
+ 'main_description': "Export Dars applications to Web",
13
+
14
+ # Commands
15
+ 'available_commands': "Available commands",
16
+ 'export_help': "Export application",
17
+ 'info_help': "Show application information",
18
+ 'formats_help': "Show supported formats",
19
+ 'preview_help': "Preview information",
20
+ 'property_column': "Property",
21
+ 'value_column': "Value",
22
+ 'argument_column': "Argument",
23
+ 'description_column': "Description",
24
+ 'preview_cmd_help': "Preview exported application",
25
+ 'init_help': "Create a Dars project",
26
+ 'template_not_found': "Template '{template}' not found",
27
+ 'extra_file_copied': "Extra file '{file}' copied",
28
+
29
+ # Export command
30
+ 'file_help': "Python file with Dars application",
31
+ 'format_help': "Export format",
32
+ 'output_help': "Output directory",
33
+ 'preview_arg_help': "Show preview information (HTML only)",
34
+
35
+ # Init command
36
+ 'name_help': "Project name",
37
+ 'template_help': "Initial template: category/name (e.g. basic/hello_world)",
38
+
39
+ # Preview command
40
+ 'path_help': "Directory with exported application",
41
+ 'preview_description': "Dars Preview - Preview system",
42
+ 'directory_help': "Directory with the exported application",
43
+ 'no_open_help': "Do not automatically open the browser",
44
+ 'port_help': "Port for the server (HTML only)",
45
+ 'lang_help': "Language for the preview (en or es)",
46
+
47
+ # Preview server messages
48
+ 'server_start_error': "Error starting server: {error}",
49
+ 'preview_server_started': "Preview server started",
50
+ 'directory': "Directory",
51
+ 'port': "Port",
52
+ 'press_ctrl_c': "Press Ctrl+C to stop the server",
53
+ 'opening_in_browser': "Opening in browser: {url}",
54
+ 'browser_open_error': "Could not open browser automatically: {error}",
55
+ 'open_manually': "Open manually: {url}",
56
+ 'stopping_server': "Stopping server...",
57
+ 'server_stopped': "Server stopped",
58
+
59
+ # Preview HTML app
60
+ 'html_preview': "HTML Preview",
61
+ 'index_html_missing': "Error: index.html not found in {directory}",
62
+
63
+ # Preview React app
64
+ 'react_preview': "React App Preview",
65
+ 'react_package_json_missing': "Error: package.json not found in {directory}",
66
+ 'package_json_not_found': "Error: package.json not found in",
67
+ 'preview_react_instructions': "How to preview React app",
68
+ 'navigate_to_directory': "Navigate to the directory",
69
+ 'install_dependencies': "Install dependencies",
70
+ 'start_dev_server': "Start the development server",
71
+ 'app_will_open': "The app will open automatically in your browser:",
72
+ 'react_navigate': "1. Navigate to the directory: cd {directory}",
73
+ 'react_install': "2. Install dependencies: npm install",
74
+ 'react_start': "3. Start the development server: npm start",
75
+ 'react_auto_open': "The app will open automatically in your browser",
76
+
77
+ # Preview React Native app
78
+ 'react_native_preview': "React Native App Preview",
79
+ 'react_native_package_json_missing': "Error: package.json not found in {directory}",
80
+ 'preview_react_native_instructions': "How to preview React Native app",
81
+ 'for_android': "For Android",
82
+ 'for_ios': "For iOS",
83
+ 'start_metro': "Start Metro bundler",
84
+ 'react_native_navigate': "1. Navigate to the directory: cd {directory}",
85
+ 'react_native_install': "2. Install dependencies: npm install",
86
+ 'react_native_android': "3. For Android: npm run android",
87
+ 'react_native_ios': "4. For iOS: npm run ios",
88
+ 'react_native_start': "5. Start Metro bundler: npm start",
89
+ 'react_native_note': "Note: Make sure you have the React Native development environment set up",
90
+
91
+ # Preview PySide6 app
92
+ 'pyside6_preview': "PySide6 App Preview",
93
+ 'pyside6_main_missing': "Error: main.py not found in {directory}",
94
+ 'main_py_not_found': "Error: main.py not found in",
95
+ 'run_pyside6_app': "Run PySide6 application",
96
+ 'run_application': "Run the application",
97
+ 'pyside6_navigate': "1. Navigate to the directory: cd {directory}",
98
+ 'pyside6_install': "2. Install dependencies: pip install -r requirements.txt (if available)",
99
+ 'pyside6_run': "3. Run the application: python main.py",
100
+ 'pyside6_note': "Note: Make sure you have PySide6 installed (pip install pyside6)",
101
+
102
+ # Preview C# app
103
+ 'csharp_preview': "C# App Preview",
104
+ 'csharp_project_missing': "Error: No .csproj file found in {directory}",
105
+ 'run_csharp_app': "Run C# application",
106
+ 'restore_dependencies': "Restore dependencies",
107
+ 'build_application': "Build the application",
108
+ 'dotnet_note': "Note: Make sure you have the .NET SDK installed",
109
+ 'csharp_navigate': "1. Navigate to the directory: cd {directory}",
110
+ 'csharp_restore': "2. Restore dependencies: dotnet restore",
111
+ 'csharp_build': "3. Build the application: dotnet build",
112
+ 'csharp_run': "4. Run the application: dotnet run",
113
+ 'csharp_note': "Note: Make sure you have .NET SDK installed",
114
+
115
+ # Preview Kotlin app
116
+ 'kotlin_preview': "Kotlin Multiplatform App Preview",
117
+ 'kotlin_gradle_missing': "Error: build.gradle.kts not found in {directory}",
118
+ 'gradle_not_found': "Error: build.gradle.kts not found in",
119
+ 'run_kotlin_app': "Run Kotlin application",
120
+ 'for_desktop': "Run for desktop",
121
+ 'build_all_platforms': "Build for all platforms",
122
+ 'kotlin_navigate': "1. Navigate to the directory: cd {directory}",
123
+ 'kotlin_desktop': "2. Run for desktop: ./gradlew run",
124
+ 'kotlin_android': "3. Install for Android: ./gradlew installDebug",
125
+ 'kotlin_build_all': "4. Build for all platforms: ./gradlew build",
126
+ 'kotlin_note': "Note: Make sure you have JDK and Android SDK installed",
127
+
128
+ # Preview app
129
+ 'directory_not_exists': "Error: The directory {directory} does not exist",
130
+ 'format_not_detected': "Error: Could not detect the application format in {directory}",
131
+ 'detected_format': "Detected format",
132
+ 'format_not_supported': "Error: Format '{format}' not supported for preview",
133
+
134
+ # Help sections
135
+ 'usage': "USAGE",
136
+ 'positional_arguments': "POSITIONAL ARGUMENTS",
137
+ 'options': "OPTIONS",
138
+ 'commands': "AVAILABLE COMMANDS",
139
+ 'examples': "EXAMPLES",
140
+ 'help_arg_message': "show this help message and exit",
141
+
142
+ # Examples
143
+ 'usage_examples': "Usage examples",
144
+ 'examples_text': """
145
+ dars export app.py --format html --output ./dist
146
+ dars info app.py
147
+ dars preview ./dist
148
+ dars init my_new_project
149
+ dars init my_new_project -t demo/complete_app
150
+ """,
151
+
152
+ # Messages
153
+ 'app_found': "Application found at: {}",
154
+ 'open_in_browser': "Open in browser: file://{}",
155
+ 'preview_question': "Do you want to see the preview? [green]y[/green] / [red]n[/red] [y/n] ",
156
+ 'index_not_found': "index.html not found in {}",
157
+ 'dir_created': "Directory '{}' created",
158
+ 'template_copied': "Template '{template}' copied as main.py",
159
+ 'main_created': "main.py file created (default Hello World)",
160
+ 'project_initialized': "🎉 Dars project successfully initialized",
161
+ 'export_command': "To export the template use",
162
+ 'preview_command': "To view the project in a browser use",
163
+
164
+ # Formats
165
+ 'supported_export_formats': "Supported export formats",
166
+ 'supported_formats': "Supported export formats",
167
+ 'format_name': "Format",
168
+ 'format_description': "Description",
169
+ 'html_description': "Standard HTML/CSS/JavaScript",
170
+
171
+ # App info
172
+ 'app_information': "Application Information",
173
+ 'app_info': "Application Information: {}",
174
+ 'export_completed_successfully': "Export completed successfully",
175
+ 'export_successful': "Export Successful",
176
+ 'application': "Application",
177
+ 'output_directory': "Output directory",
178
+ 'statistics': "Statistics",
179
+ 'total_pages': "Total pages",
180
+ 'to_preview_app': "To preview the app",
181
+ 'or_use': "Or use",
182
+ 'view_preview': "Do you want to open the preview?",
183
+ 'error_entry_not_found_in_config': "Error: Entry file not found",
184
+ 'edit_config_hint': "Hint: check dars.config.json 'entry' path or run dars init --update",
185
+ 'error_format_only_html': "Only 'html' format is supported currently",
186
+ 'error_output_create': "Error creating output directory",
187
+ 'error_file_not_exists': "Error: File does not exist:",
188
+ 'error_file_load': "Error loading file:",
189
+ 'error_no_app_var': "Error: No 'app' variable of type App in",
190
+ 'error_loading_file': "Error loading file",
191
+ 'validation_errors': "Validation errors",
192
+ 'error_format_not_supported': "Error: Format not supported:",
193
+ 'validating_app': "Validating app...",
194
+ 'exporting_to': "Exporting to",
195
+ 'error_during_export': "Error during export to",
196
+ 'error_during_export_exception': "Exception during export",
197
+ # Config validation
198
+ 'cfg_validation_title': "dars.config.json validation",
199
+ 'cfg_item': "Item",
200
+ 'cfg_result': "Result",
201
+ 'cfg_found': "Config found",
202
+ 'cfg_not_found': "Config not found",
203
+ 'cfg_not_found_warn': "Config not found: using defaults (run 'dars init --update' to create one)",
204
+ 'cfg_entry_missing': "Entry file missing or not found: {path}",
205
+ 'cfg_entry_ok': "Entry file OK: {path}",
206
+ 'cfg_format_only_html': "Format must be 'html' (found: {fmt})",
207
+ 'cfg_format_ok': "Format OK: {fmt}",
208
+ 'cfg_outdir_ok': "Outdir creatable OK: {path}",
209
+ 'cfg_outdir_error': "Outdir cannot be created: {path} (error: {error})",
210
+ 'cfg_public_missing': "publicDir set but not found: {path}",
211
+ 'cfg_public_ok': "publicDir OK: {path}",
212
+ 'cfg_public_autodetect': "publicDir not set: will autodetect 'public/' or 'assets/' if present",
213
+ 'cfg_include_type': "'include' must be a list of strings",
214
+ 'cfg_exclude_type': "'exclude' must be a list of strings",
215
+ 'cfg_bundle_type': "'bundle' must be a boolean",
216
+ 'property': "Property",
217
+ 'value': "Value",
218
+ 'title': "Title",
219
+ 'total_components': "Total components",
220
+ 'max_depth': "Maximum depth",
221
+ 'scripts': "Scripts",
222
+ 'global_styles': "Global styles",
223
+ 'theme': "Theme",
224
+ 'responsive': "Responsive",
225
+ 'component_structure': "Component Structure"
226
+ },
227
+ 'es': {
228
+ # CLI descriptions
229
+ 'cli_description': "Dars Exporter - Exporta aplicaciones Dars a Web",
230
+ 'cli_subtitle': "Framework de UI multiplataforma en Python",
231
+ 'main_description': "Dars Exporter - Exporta aplicaciones Dars a Web",
232
+ 'template_not_found': "Template '{template}' not found",
233
+ 'extra_file_copied': "Extra file '{file}' copied",
234
+
235
+ # Commands
236
+ 'available_commands': "Comandos disponibles",
237
+ 'export_help': "Exportar aplicación",
238
+ 'info_help': "Mostrar información de la aplicación",
239
+ 'formats_help': "Mostrar formatos soportados",
240
+ 'preview_help': "Información de preview",
241
+ 'preview_cmd_help': "Previsualizar aplicación exportada",
242
+ 'init_help': "Crea un proyecto Dars",
243
+ 'property_column': "Propiedad",
244
+ 'value_column': "Valor",
245
+ 'argument_column': "Argumento",
246
+ 'description_column': "Descripción",
247
+
248
+ # Export command
249
+ 'file_help': "Archivo Python con la aplicación Dars",
250
+ 'format_help': "Formato de exportación",
251
+ 'output_help': "Directorio de salida",
252
+ 'preview_arg_help': "Mostrar información de preview (solo para HTML)",
253
+
254
+ # Init command
255
+ 'name_help': "Nombre del proyecto",
256
+ 'template_help': "Plantilla inicial: categoría/nombre (por ejemplo basic/hello_world)",
257
+
258
+ # Preview command
259
+ 'path_help': "Directorio con la aplicación exportada",
260
+ 'preview_description': "Dars Preview - Sistema de preview",
261
+ 'directory_help': "Directorio con la aplicación exportada",
262
+ 'no_open_help': "No abrir automáticamente el navegador",
263
+ 'port_help': "Puerto para el servidor (solo HTML)",
264
+ 'lang_help': "Idioma para la preview (en o es)",
265
+
266
+ # Preview server messages
267
+ 'server_start_error': "Error al iniciar el servidor: {error}",
268
+ 'preview_server_started': "Servidor de preview iniciado",
269
+ 'directory': "Directorio",
270
+ 'port': "Puerto",
271
+ 'press_ctrl_c': "Presiona Ctrl+C para detener el servidor",
272
+ 'opening_in_browser': "Abriendo en navegador: {url}",
273
+ 'browser_open_error': "No se pudo abrir el navegador automáticamente: {error}",
274
+ 'open_manually': "Abrir manualmente: {url}",
275
+ 'stopping_server': "Deteniendo servidor...",
276
+ 'server_stopped': "Servidor detenido",
277
+
278
+ # Preview HTML app
279
+ 'html_preview': "Preview HTML",
280
+ 'index_html_missing': "Error: No se encontró index.html en {directory}",
281
+
282
+ # Preview React app
283
+ 'react_preview': "Preview de App React",
284
+ 'react_package_json_missing': "Error: No se encontró package.json en {directory}",
285
+ 'package_json_not_found': "Error: No se encontró package.json en",
286
+ 'preview_react_instructions': "Cómo previsualizar app React",
287
+ 'navigate_to_directory': "Navega al directorio",
288
+ 'install_dependencies': "Instala dependencias",
289
+ 'start_dev_server': "Inicia el servidor de desarrollo",
290
+ 'app_will_open': "La app se abrirá automáticamente en tu navegador:",
291
+ 'react_navigate': "1. Navega al directorio: cd {directory}",
292
+ 'react_install': "2. Instala dependencias: npm install",
293
+ 'react_start': "3. Inicia el servidor de desarrollo: npm start",
294
+ 'react_auto_open': "La aplicación se abrirá automáticamente en tu navegador",
295
+
296
+ # Preview React Native app
297
+ 'react_native_preview': "Preview de App React Native",
298
+ 'react_native_package_json_missing': "Error: No se encontró package.json en {directory}",
299
+ 'preview_react_native_instructions': "Cómo previsualizar app React Native",
300
+ 'for_android': "Para Android",
301
+ 'for_ios': "Para iOS",
302
+ 'start_metro': "Inicia Metro bundler",
303
+ 'react_native_navigate': "1. Navega al directorio: cd {directory}",
304
+ 'react_native_install': "2. Instala dependencias: npm install",
305
+ 'react_native_android': "3. Para Android: npm run android",
306
+ 'react_native_ios': "4. Para iOS: npm run ios",
307
+ 'react_native_start': "5. Inicia Metro bundler: npm start",
308
+ 'react_native_note': "Nota: Asegúrate de tener configurado el entorno de desarrollo de React Native",
309
+
310
+ # Preview PySide6 app
311
+ 'pyside6_preview': "Preview de App PySide6",
312
+ 'pyside6_main_missing': "Error: No se encontró main.py en {directory}",
313
+ 'main_py_not_found': "Error: No se encontró main.py en",
314
+ 'run_pyside6_app': "Ejecutar aplicación PySide6",
315
+ 'run_application': "Ejecutar la aplicación",
316
+ 'pyside6_navigate': "1. Navega al directorio: cd {directory}",
317
+ 'pyside6_install': "2. Instala dependencias: pip install -r requirements.txt (si está disponible)",
318
+ 'pyside6_run': "3. Ejecuta la aplicación: python main.py",
319
+ 'pyside6_note': "Nota: Asegúrate de tener PySide6 instalado (pip install pyside6)",
320
+
321
+ # Preview C# app
322
+ 'csharp_preview': "Preview de App C#",
323
+ 'csharp_project_missing': "Error: No se encontró archivo .csproj en {directory}",
324
+ 'run_csharp_app': "Ejecutar aplicación C#",
325
+ 'restore_dependencies': "Restaura dependencias",
326
+ 'build_application': "Compila la aplicación",
327
+ 'dotnet_note': "Nota: Asegúrate de tener instalado .NET SDK",
328
+ 'csharp_navigate': "1. Navega al directorio: cd {directory}",
329
+ 'csharp_restore': "2. Restaura dependencias: dotnet restore",
330
+ 'csharp_build': "3. Compila la aplicación: dotnet build",
331
+ 'csharp_run': "4. Ejecuta la aplicación: dotnet run",
332
+ 'csharp_note': "Nota: Asegúrate de tener instalado .NET SDK",
333
+
334
+ # Preview Kotlin app
335
+ 'kotlin_preview': "Preview de App Kotlin Multiplatform",
336
+ 'kotlin_gradle_missing': "Error: No se encontró build.gradle.kts en {directory}",
337
+ 'gradle_not_found': "Error: No se encontró build.gradle.kts en",
338
+ 'run_kotlin_app': "Ejecutar aplicación Kotlin",
339
+ 'for_desktop': "Ejecutar para desktop",
340
+ 'build_all_platforms': "Compilar para todas las plataformas",
341
+ 'kotlin_navigate': "1. Navega al directorio: cd {directory}",
342
+ 'kotlin_desktop': "2. Ejecutar para desktop: ./gradlew run",
343
+ 'kotlin_android': "3. Instalar para Android: ./gradlew installDebug",
344
+ 'kotlin_build_all': "4. Compilar para todas las plataformas: ./gradlew build",
345
+ 'kotlin_note': "Nota: Asegúrate de tener instalado JDK y Android SDK",
346
+
347
+ # Preview app
348
+ 'directory_not_exists': "Error: El directorio {directory} no existe",
349
+ 'format_not_detected': "Error: No se pudo detectar el formato de la aplicación en {directory}",
350
+ 'detected_format': "Formato detectado",
351
+ 'format_not_supported': "Error: Formato '{format}' no soportado para preview",
352
+
353
+ # Help sections
354
+ 'usage': "USO",
355
+ 'positional_arguments': "ARGUMENTOS POSICIONALES",
356
+ 'options': "OPCIONES",
357
+ 'commands': "COMANDOS DISPONIBLES",
358
+ 'examples': "EJEMPLOS",
359
+ 'help_arg_message': "muestra este mensaje de ayuda y sal",
360
+
361
+ # Examples
362
+ 'usage_examples': "Ejemplos de uso",
363
+ 'examples_text': """
364
+ dars export app.py --format html --output ./dist
365
+ dars info app.py
366
+ dars preview ./dist
367
+ dars init mi_nuevo_proyecto
368
+ dars init mi_nuevo_proyecto -t demo/complete_app
369
+ """,
370
+
371
+ # Messages
372
+ 'app_found': "Aplicación encontrada en: {}",
373
+ 'open_in_browser': "Abrir en navegador: file://{}",
374
+ 'preview_question': "¿Quieres ver la preview? [green]y[/green] / [red]n[/red] [y/n] ",
375
+ 'index_not_found': "No se encontró index.html en {}",
376
+ 'dir_created': "Directorio '{}' creado",
377
+ 'template_copied': "Template '{template}' copiado como main.py",
378
+ 'main_created': "Archivo main.py creado (Hello World por defecto)",
379
+ 'project_initialized': "🎉 Proyecto Dars inicializado exitosamente",
380
+ 'export_command': "Para exportar el template usa",
381
+ 'preview_command': "Para ver el proyecto en un navegador usa",
382
+
383
+ # Formats
384
+ 'supported_export_formats': "Formatos de exportación soportados",
385
+ 'supported_formats': "Formatos de exportación soportados",
386
+ 'format_name': "Formato",
387
+ 'format_description': "Descripción",
388
+ 'html_description': "HTML/CSS/JavaScript estándar",
389
+
390
+ # App info
391
+ 'app_information': "Información de la Aplicación",
392
+ 'app_info': "Información de la Aplicación: {}",
393
+ 'export_completed_successfully': "Exportación completada exitosamente",
394
+ 'export_successful': "Exportación Exitosa",
395
+ 'application': "Aplicación",
396
+ 'output_directory': "Directorio de salida",
397
+ 'statistics': "Estadísticas",
398
+ 'total_pages': "Páginas totales",
399
+ 'to_preview_app': "Para previsualizar la app",
400
+ 'or_use': "O usa",
401
+ 'view_preview': "¿Quieres abrir la previsualización?",
402
+ 'error_entry_not_found_in_config': "Error: No se encontró el archivo de entrada",
403
+ 'edit_config_hint': "Pista: revisa 'entry' en dars.config.json o ejecuta dars init --update",
404
+ 'error_format_only_html': "Actualmente solo se soporta el formato 'html'",
405
+ 'error_output_create': "Error al crear el directorio de salida",
406
+ 'error_file_not_exists': "Error: El archivo no existe:",
407
+ 'error_file_load': "Error al cargar archivo:",
408
+ 'error_no_app_var': "Error: No hay variable 'app' de tipo App en",
409
+ 'error_loading_file': "Error cargando archivo",
410
+ 'validation_errors': "Errores de validación",
411
+ 'error_format_not_supported': "Error: Formato no soportado:",
412
+ 'validating_app': "Validando aplicación...",
413
+ 'exporting_to': "Exportando a",
414
+ 'error_during_export': "Error durante exportación a",
415
+ 'error_during_export_exception': "Excepción durante exportación",
416
+ # Config validation
417
+ 'cfg_validation_title': "Validación de dars.config.json",
418
+ 'cfg_item': "Ítem",
419
+ 'cfg_result': "Resultado",
420
+ 'cfg_found': "Config encontrada",
421
+ 'cfg_not_found': "Config no encontrada",
422
+ 'cfg_not_found_warn': "Config no encontrada: usando valores por defecto (ejecuta 'dars init --update' para crearla)",
423
+ 'cfg_entry_missing': "Archivo de entrada faltante o no encontrado: {path}",
424
+ 'cfg_entry_ok': "Archivo de entrada OK: {path}",
425
+ 'cfg_format_only_html': "El formato debe ser 'html' (encontrado: {fmt})",
426
+ 'cfg_format_ok': "Formato OK: {fmt}",
427
+ 'cfg_outdir_ok': "Directorio de salida creable OK: {path}",
428
+ 'cfg_outdir_error': "No se puede crear el directorio de salida: {path} (error: {error})",
429
+ 'cfg_public_missing': "publicDir definido pero no encontrado: {path}",
430
+ 'cfg_public_ok': "publicDir OK: {path}",
431
+ 'cfg_public_autodetect': "publicDir no definido: se autodetectará 'public/' o 'assets/' si existen",
432
+ 'cfg_include_type': "'include' debe ser una lista de strings",
433
+ 'cfg_exclude_type': "'exclude' debe ser una lista de strings",
434
+ 'cfg_bundle_type': "'bundle' debe ser booleano",
435
+ 'property': "Propiedad",
436
+ 'value': "Valor",
437
+ 'title': "Título",
438
+ 'total_components': "Componentes totales",
439
+ 'max_depth': "Profundidad máxima",
440
+ 'scripts': "Scripts",
441
+ 'global_styles': "Estilos globales",
442
+ 'theme': "Tema",
443
+ 'responsive': "Responsive",
444
+ 'component_structure': "Estructura de Componentes"
445
+ }
446
+ }
447
+
448
+ import os
449
+ import configparser
450
+
451
+ class Translator:
452
+ """Class for handling translations"""
453
+
454
+ def __init__(self, language='en'):
455
+ self.config_file = self._get_config_path()
456
+ self.language = self._load_language_preference() or language
457
+
458
+ def _get_config_path(self):
459
+ """Returns the path to the configuration file"""
460
+ # Use user's home directory for configuration
461
+ home_dir = os.path.expanduser("~")
462
+ dars_config_dir = os.path.join(home_dir, ".dars")
463
+
464
+ # Create the directory if it doesn't exist
465
+ if not os.path.exists(dars_config_dir):
466
+ os.makedirs(dars_config_dir)
467
+
468
+ return os.path.join(dars_config_dir, "config.ini")
469
+
470
+ def _load_language_preference(self):
471
+ """Loads the language preference from the configuration file"""
472
+ config = configparser.ConfigParser()
473
+
474
+ if os.path.exists(self.config_file):
475
+ config.read(self.config_file)
476
+ if 'preferences' in config and 'language' in config['preferences']:
477
+ lang = config['preferences']['language']
478
+ if lang in translations:
479
+ return lang
480
+ return None
481
+
482
+ def _save_language_preference(self):
483
+ """Saves the current language preference to the configuration file"""
484
+ config = configparser.ConfigParser()
485
+
486
+ # Load existing config if it exists
487
+ if os.path.exists(self.config_file):
488
+ config.read(self.config_file)
489
+
490
+ # Ensure the preferences section exists
491
+ if 'preferences' not in config:
492
+ config['preferences'] = {}
493
+
494
+ # Update the language preference
495
+ config['preferences']['language'] = self.language
496
+
497
+ # Save the configuration
498
+ with open(self.config_file, 'w') as configfile:
499
+ config.write(configfile)
500
+
501
+ def set_language(self, language, save=True):
502
+ """Sets the current language and optionally saves the preference"""
503
+ if language in translations:
504
+ self.language = language
505
+ if save:
506
+ self._save_language_preference()
507
+ else:
508
+ print(f"Language {language} not supported, using default (en)")
509
+ self.language = 'en'
510
+ if save:
511
+ self._save_language_preference()
512
+
513
+ def get(self, key, **kwargs):
514
+ """Gets a translation by its key"""
515
+ if self.language in translations and key in translations[self.language]:
516
+ text = translations[self.language][key]
517
+ # Apply formatting if there are arguments
518
+ if kwargs:
519
+ return text.format(**kwargs)
520
+ return text
521
+ # Fallback to English if the key is not found in current language
522
+ if 'en' in translations and key in translations['en']:
523
+ text = translations['en'][key]
524
+ if kwargs:
525
+ return text.format(**kwargs)
526
+ return text
527
+ # If not found in any language, return the key
528
+ return key
529
+
530
+ # Instancia global del traductor
531
+ translator = Translator()
File without changes
@@ -0,0 +1,8 @@
1
+ from .card import Card
2
+ from .modal import Modal
3
+ from .navbar import Navbar
4
+ from .table import Table
5
+ from .tabs import Tabs
6
+ from .accordion import Accordion
7
+
8
+ __all__ = ['Card', 'Modal', 'Navbar', 'Table', 'Tabs', 'Accordion']
@@ -0,0 +1,26 @@
1
+ from dars.core.component import Component
2
+ from typing import List, Optional
3
+
4
+ class Accordion(Component):
5
+ """
6
+ Accordion component to display collapsible sections.
7
+ sections: List of tuples (title, content)
8
+ open_indices: List of open indices (optional)
9
+ """
10
+
11
+ def __init__(self, sections: List[tuple], open_indices: Optional[List[int]]=None, minimum_logic: bool = True, **props):
12
+ super().__init__(**props)
13
+ self.sections = sections
14
+ self.open_indices = open_indices or []
15
+ self.minimum_logic = minimum_logic
16
+ for _, content in sections:
17
+ if hasattr(content, 'render'):
18
+ self.add_child(content)
19
+
20
+ def render(self) -> str:
21
+ html = '<div class="dars-accordion">'
22
+ for i, (title, content) in enumerate(self.sections):
23
+ opened = ' dars-accordion-open' if i in self.open_indices else ''
24
+ html += f'<div class="dars-accordion-section{opened}"><div class="dars-accordion-title">{title}</div><div class="dars-accordion-content">{content.render() if hasattr(content, "render") else content}</div></div>'
25
+ html += '</div>'
26
+ return html
@@ -0,0 +1,33 @@
1
+ from dars.core.component import Component
2
+ from typing import Optional, Dict, Any, List
3
+
4
+ class Card(Component):
5
+ """Component to display content in a card."""
6
+ def __init__(
7
+ self,
8
+ children: Optional[List[Component]] = None,
9
+ title: Optional[str] = None,
10
+ class_name: Optional[str] = None,
11
+ style: Optional[Dict[str, Any]] = None,
12
+ minimum_logic: bool = True,
13
+ **kwargs
14
+ ):
15
+ super().__init__(class_name=class_name, style=style, **kwargs)
16
+ self.title = title
17
+ self.minimum_logic = minimum_logic
18
+ if children:
19
+ for child in children:
20
+ self.add_child(child)
21
+
22
+ def render(self) -> str:
23
+ title_html = f'<h2>{self.title}</h2>' if self.title else ''
24
+ children_html = ''.join([child.render() for child in self.children])
25
+
26
+ attrs = []
27
+ if self.class_name: attrs.append(f'class="dars-card {self.class_name}"')
28
+ else: attrs.append('class="dars-card"')
29
+ if self.style: attrs.append(f'style="{self.render_styles(self.style)}"')
30
+
31
+ return f'<div {" ".join(attrs)}>{title_html}{children_html}</div>'
32
+
33
+
@@ -0,0 +1,45 @@
1
+ from dars.core.component import Component
2
+ from typing import Optional, Dict, Any, List
3
+
4
+ class Modal(Component):
5
+ """Component to display content in a modal."""
6
+ def __init__(
7
+ self,
8
+ children: Optional[List[Component]] = None,
9
+ title: Optional[str] = None,
10
+ is_open: bool = False,
11
+ class_name: Optional[str] = None,
12
+ style: Optional[Dict[str, Any]] = None,
13
+ minimum_logic: bool = True,
14
+ **kwargs
15
+ ):
16
+ super().__init__(class_name=class_name, style=style, **kwargs)
17
+ self.title = title
18
+ self.is_open = is_open
19
+ self.minimum_logic = minimum_logic
20
+ if children:
21
+ for child in children:
22
+ self.add_child(child)
23
+
24
+ def render(self) -> str:
25
+ title_html = f'<h2>{self.title}</h2>' if self.title else ''
26
+ children_html = ''.join([child.render() for child in self.children])
27
+
28
+ display_style = 'display: flex' if self.is_open else 'display: none'
29
+
30
+ attrs = []
31
+ if self.class_name: attrs.append(f'class="dars-modal {self.class_name}"')
32
+ else: attrs.append('class="dars-modal"')
33
+
34
+ modal_style = f'{display_style}; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 1000'
35
+ if self.style:
36
+ modal_style += f'; {self.render_styles(self.style)}'
37
+ attrs.append(f'style="{modal_style}"')
38
+
39
+ return f'''<div {" ".join(attrs)}>
40
+ <div class="dars-modal-content" style="background: white; padding: 20px; border-radius: 8px; max-width: 500px; width: 90%;">
41
+ {title_html}
42
+ {children_html}
43
+ </div>
44
+ </div>'''
45
+