hledger icon indicating copy to clipboard operation
hledger copied to clipboard

Support customization/localization of reports

Open mildred opened this issue 6 years ago • 5 comments

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

mildred avatar May 14 '19 13:05 mildred

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 avatar May 14 '19 13:05 simonmichael

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 avatar Jul 24 '20 12:07 simonmichael

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

simonmichael avatar Jul 24 '20 13:07 simonmichael

Open questions:

  • in current compound balance reports, each subsection shows an account type. In the mockups above they are based on arbitrary queries, and account types aren't mentioned. What would account types be used for ?
  • the above doesn't really address how to localise headings of the standard builtin reports (bs/bse/cf/is), unless we allowed custom commands to override builtin commands, and it would still be a bit over-complex and error-prone.
  • it would be useful to be able to localise the standard report titles once eg in a user config file, and not have to do it in every journal or on every command line.
  • it could be useful to start doing traditional l10n, building in translations of the standard report titles and selecting them based on system locale with no configuration needed. There would need to be a way to override this.

simonmichael avatar Jul 24 '20 14:07 simonmichael

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?

alerque avatar Apr 10 '24 19:04 alerque