Add critical rules: always Tailwind, always translate user text

- Strengthen CLAUDE.md rule 8: Tailwind with no exceptions
- Add CLAUDE.md rule 13: all user-visible text must use translation
  functions (Twig: | translate, PHP: t_var(), JS: CmsApi.t_var())
- Add t_var() reference to hooks-and-api.md and css-js-conventions.md
- Update translate entry in quick-reference.md with all 3 contexts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 10:19:22 +00:00
parent d1b78fb420
commit 05008c0045
4 changed files with 14 additions and 2 deletions

View File

@@ -99,11 +99,12 @@ Do NOT modify web-base files — they are shared across all projects.
5. Table names without `cms_` prefix everywhere
6. Primary key is `num`, never `id`
7. Upload fields are arrays — access with `[0].urlPath`
8. Tailwind CSS as primary styling, custom CSS scoped with BEM when needed
8. **Always use Tailwind CSS.** No exceptions — every style must use Tailwind utility classes. Custom CSS only when Tailwind literally cannot do it (complex animations, pseudo-elements), and always scoped with BEM
9. Twig concatenation uses `~` operator: `'value=' ~ variable`
10. `enlace` (link) fields already include slashes
11. **File hooks (`hooks/*.php`) do NOT inject variables.** Always read params manually: `$params = json_decode(file_get_contents('php://input'), true) ?: [];` — Only module hooks (`modulos/*/hook.php`) receive variables directly.
12. **`tipo` is a reserved variable.** The `.htaccess` injects `tipo=barra` on every request. Never use `tipo` as a hook parameter name — it gets overwritten, causing 404s. Use `account_type`, `user_tipo`, etc.
13. **All user-visible text must use translation functions.** Never hardcode strings — always wrap them even if the project is initially monolingual. Twig: `{{ 'Text' | translate }}`, PHP: `t_var('Text')`, JS: `CmsApi.t_var('Text')`. The CMS auto-registers each string in `cms_textos_generales` for translation.
## Documentation

View File

@@ -96,6 +96,12 @@ CmsApi.hook('/hooks/module_id/', { action: 'getData', id: 123 }).then(function(r
});
```
### Traducción en JavaScript
Todo texto visible al usuario debe usar `CmsApi.t_var()`:
```js
CmsApi.t_var('Inicia sesión para guardar favoritos');
```
### Cuándo usar Vue 3
Usar Vue 3 CDN cuando la lógica requiera:

View File

@@ -193,6 +193,11 @@ CmsApi::delete('productos',
- Foreign keys: el nombre es **exactamente** el definido en el schema (`.ini.php`). A veces es `categoria_num`, a veces `categoria`. Siempre consultar el schema antes de asumir
- Upload fields: no se manejan via insert/update
- Operadores: `=`, `!=`, `>`, `>=`, `<`, `<=`, `LIKE`, `IN`
- **Traducción en PHP:** Usar `t_var()` para todo texto visible al usuario:
```php
return ['error' => t_var('Debes iniciar sesión')];
return ['success' => t_var('Datos guardados correctamente')];
```
---

View File

@@ -55,7 +55,7 @@
| `module` | `'module_id' \| module({params})` |
| `queryDB` | `'SELECT ...' \| queryDB()` |
| `imagec` | `path \| imagec(width)` |
| `translate` | `'text' \| translate` |
| `translate` | `'text' \| translate` (Twig) / `t_var('text')` (PHP) / `CmsApi.t_var('text')` (JS) |
| `json_decode` | `'json_string' \| json_decode` |
| `raw` | `variable \| raw` |
| `truncate` | `text \| truncate(100)` |