# Autogedal_FrontendI18n

Console command to collect frontend or backend phrases from specific Magento frontend or admin roots and append missing rows to an existing translation CSV file in place.
Frontend mode scans `app/design/frontend` plus `app/code/*/*/view/frontend`.
Frontend mode also scans `app/code/*/*/Block` files that are not under `Adminhtml`.
Frontend mode also scans `app/code/*/*/Controller` files that are not under `Adminhtml`.
Backend mode scans `app/design/adminhtml` plus `app/code/*/*/view/adminhtml` and `app/code/*/*/Block/Adminhtml`.
Backend mode also scans `app/code/*/*/Controller/Adminhtml`.
The collector only reads translatable file types: `php`, `phtml`, `html`, `xml`, and `js`.
It skips obvious generated/static folders such as `generated`, `var`, `pub`, `static`, `vendor`, and `node_modules`.
It also skips obvious admin-config help text in storefront files, such as phrases pointing to `Stores -> Configuration` or `Content -> Elements`.
The duplicate checker reuses `TranslationComparator` to report repeated source strings in a CSV, including the first line, duplicate line, and whether the translations differ.

## Command

```bash
bin/magento autogedal:i18n:collect \
  --area=frontend \
  --csv=app/design/frontend/Smartwave/portochild/i18n/ro_RO.csv
```

```bash
bin/magento autogedal:i18n:collect \
  --area=frontend \
  --include-vendor \
  --csv=app/design/frontend/Smartwave/portochild/i18n/ro_RO.csv
```

```bash
bin/magento autogedal:i18n:compare \
  --area=frontend \
  --target-csv=app/design/frontend/Smartwave/portochild/i18n/ro_RO.csv \
  --different-output=var/i18n/ro_RO.module-vs-portochild.different.csv \
  --missing-output=var/i18n/ro_RO.module-vs-portochild.missing.csv
```

```bash
bin/magento autogedal:i18n:compare \
  --area=frontend \
  --exclude-module-prefix=Autogedal \
  --exclude-module-prefix=Leadlion \
  --target-csv=app/design/frontend/Smartwave/portochild/i18n/ro_RO.csv \
  --different-output=var/i18n/ro_RO.module-vs-portochild.different.csv \
  --missing-output=var/i18n/ro_RO.module-vs-portochild.missing.csv
```

```bash
bin/magento autogedal:i18n:duplicates \
  --csv=app/design/frontend/Leadlion/autogedal/i18n/ro_RO.csv \
  --output=var/i18n/ro_RO.duplicates.csv
```

## Options

- `--area=frontend|backend`
- `--csv=/path/to/final/translation.csv` such as `app/design/frontend/Smartwave/portochild/i18n/ro_RO.csv`
- `--ignore-csv=/path/to/ignored.csv` such as `app/code/Leadlion/Autogedal/i18n/ro_RO.csv`
- `--append`
- `--include-vendor` also scans matching vendor module paths under `vendor/*/*`
- `autogedal:i18n:compare` scans every `app/code/*/*/i18n/ro_RO.csv` file and compares each source row against the target Portochild CSV.
- `--exclude-module-prefix=Name` can be repeated to ignore namespaces such as `Autogedal` and `Leadlion` when you only want third-party module drift.
- `--different-output=/path/to/different.csv` writes rows where the module translation and Portochild translation differ.
- `--missing-output=/path/to/missing.csv` writes rows that exist in modules but not in Portochild.
- `autogedal:i18n:duplicates` scans one CSV file and reports repeated source rows.
- `--csv=/path/to/translation.csv` selects the file to inspect for duplicates.
- `--output=/path/to/report.csv` writes the duplicate report. If omitted, the command writes to `var/i18n/<filename>.duplicates.csv`.

## Behavior

- If `--csv` does not exist, the command creates it and writes missing rows into it.
- If `--csv` already exists, the command prompts:
  - append only new rows
  - provide a new path
  - cancel
- If `--append` is set, the command appends only rows that are not already present in the CSV.
- Missing rows are written as `source,source` so the CSV stays valid and can be translated later without breaking the format.
- If `--ignore-csv` is provided, any source phrase already present in those CSV files is skipped.
- If `--include-vendor` is provided, the collector also scans vendor module paths and vendor view/controller files for translatable phrases.
- The compare command writes two CSV reports: one for differing translations and one for rows missing from the target CSV.
- The duplicate command writes one CSV report with the first occurrence, duplicate occurrence, translations, and status.
