hi,
i looking for a best way to translate a backoffice content.
options:

A- i can use a separate file each for a lang with all vars.
B- use a table with all data

both of this solutions have a big time to implement and in all areas that i creat
i need add the vars.
there is some best solution for this?
something that can translate all content like google translator?
thanks for your help
:)

Dani AI

Generated

Both approaches already suggested on this thread are valid and commonly used: outlined a per‑module language file approach, and is using PHP defines. Each has tradeoffs: file‑based translations are simple, versionable, and fast; database storage lets non‑developers edit strings at runtime and makes mass updates easier. Pick the model that matches how often translations change and who will maintain them.

A practical, maintainable pattern is a small translation API plus a canonical store. Use a single wrapper (for example t(...)) across the app so you can change storage later without touching templates. Prefer a file format that supports tooling and plural forms (gettext PO/MO or structured JSON/YAML) as the source of truth and, if you need runtime editing, implement DB overrides that shadow those files. Always use parameter placeholders instead of string concatenation, and handle plurals and context explicitly so translations remain grammatically correct.

Implementation sketch:

  • Add a central t(key, params, count) wrapper that returns the translated string and handles fallbacks.
  • Extract all current strings (defines or arrays) into per‑module resource files, or generate a POT/JSON file for translators.
  • Choose storage: files for speed; DB for editability; use a hybrid (files in VCS + DB overrides) if you want both.
  • Add caching (opcode, memcached/redis or compiled MO files) to avoid DB lookups on every request.
  • Log missing keys and convert strings gradually, module by module.

Cautions and tips: use UTF‑8 everywhere, plan for RTL locales, handle date/number formatting with locale helpers, and never concatenate translated fragments. Automated services (Google/DeepL) can speed initial translation but require human review for UI text. Migrate incrementally and test each page after replacing old defines so layout and grammar stay correct.

Recommended Answers

All 2 Replies

One way this is done is define all of your text as variables as follows:

$MOD_NEWS['TEXT_READ_MORE'] = 'Read More';
$MOD_NEWS['TEXT_POSTED_BY'] = 'Posted by';
$MOD_NEWS['TEXT_ON'] = 'on';

That would be your English module (e.g. en.php) You then produce a module with the same variable names with the appropriate translated text for each of the other languages. The French version (fr.php) would look like:

$MOD_NEWS['TEXT_READ_MORE'] = 'En savoir plus';
$MOD_NEWS['TEXT_POSTED_BY'] = 'Posté par';
$MOD_NEWS['TEXT_ON'] = 'à';

These all reside in a languages directory and you include the appropriate version based on a system-wide parameter for language that you set in a config module.

hi,
i have something like that:
pt.php -> DEFINE( "_analises", "Análises" );

and in backoffice simple put: echo _analises;
with this i have a lot of work may be someone have a easy way to do this?
something like google translator?
thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.