simonmichael / hledger

Robust, fast, intuitive plain text accounting tool with CLI, TUI and web interfaces.
https://hledger.org
GNU General Public License v3.0
3.03k stars 321 forks source link

Support customization/localization of reports #1025

Open mildred opened 5 years ago

mildred commented 5 years ago

Reports (such as balance sheet or income statement) should be able to be customized so they can be localized and translated.

Some simple words like Assets or Liabilities must be customized (in French, it corresponds to Actif and Passif)

Split from #1006

simonmichael commented 5 years ago

Agreed! Thanks for the issue. We need someone to research and/or build a small prototype, eg localising just the title of the balancesheet report. Also, to think about hledger as a whole and clarify which parts can/should be localised. Could you help ?

simonmichael commented 4 years ago

Let's focus this issue on just:

  1. making the "financial statement" balance reports (bs, bse, cf, is) localisable, particularly their main and sub titles

and maybe (because they seem to fit well together based on the discussion at related PR #1219):

  1. allowing custom similar reports with user-defined command name & help, main title, subsection titles and content

How to define custom reports ? It could be done with command line options and/or new directives in the journal. Some quick ideas:

# the balance-report directive would define custom compound balance reports like bs/is:
balance-report Balance Sheet
  command balancesheet bs
  help
    This is a balance sheet report, showing historical asset and liability balances.
  subsection Assets
    query acct:assets
    balance-type historical
  subsection Liabilities
    query acct:liabilities
    balance-type historical
# more general: the command directive would define custom commands, as aliases for
# other hledger commands (only; we probably could not allow general commands to be called
# via directives in a journal file). The balancereport command would generate custom compound
# balance reports based on its arguments.
command balancesheet bs
  help
    This is a balance sheet report, showing historical asset and liability balances.
  balancereport 'Balance Sheet' 'Assets' 'acct:assets' historical 'Liabilities' 'acct:liabilities' historical
simonmichael commented 4 years ago

Perhaps implementing the flexible balancereport command would be a good start. Help welcome, including a better name for it.

simonmichael commented 4 years ago

Open questions:

alerque commented 7 months ago

Also things like month names should follow the output locale:

$ LANG=tr_TR.UTF-8 hledger -f=maliye.ledger bal Daire --transpose --no-total --empty -M
     ||  Daire 1   Daire 2   Daire 3   Daire 4   Daire 5
=====++==================================================
 Jan || ₺-250,00         0         0  ₺-250,00         0
 Feb || ₺-250,00         0         0  ₺-250,00         0
 Mar || ₺-250,00         0         0  ₺-250,00         0
 Apr || ₺-250,00  ₺-250,00  ₺-250,00  ₺-250,00  ₺-250,00

Should be:

     ||  Daire 1   Daire 2   Daire 3   Daire 4   Daire 5
=====++==================================================
 Oca || ₺-250,00         0         0  ₺-250,00         0
 Şub || ₺-250,00         0         0  ₺-250,00         0
 Mar || ₺-250,00         0         0  ₺-250,00         0
 Nis || ₺-250,00  ₺-250,00  ₺-250,00  ₺-250,00  ₺-250,00

Also a CLI flag to turn off the month name substitutions and include dates (as seen in -O csv for the same query) might be in order no matter the state of languages.

So is there a Project Fluent library for Haskell?