How to know which translation csv file(s) are used in the current phtml file

I assume you mean translations by $this->__('...') where no explict helper is used. Then it depends on the block's module scope

This depends on multiple factors:

  1. The block class being used to render the template. You should be able to determine it from the layout XML files, but some blocks are created programmatically, in this case you'll have to search in the code. If you are lucky, the block class is documented in the template itself, like this:

     /** @var $this Mage_Catalog_Block_Product_List */
    

    or like this:

     /** @see Mage_Catalog_Block_Product_List */
    

    The scope is the module this class belongs to (like Mage_Catalog). But be careful with class rewrites. If the block class has been rewritten by an extension, the scope changes to this extension.

  2. If the property module_name has been set (for example via layout XML), this takes precedence.

  3. Finally, if the block overrides the getModuleName() method, the scope returned from this method is used.

Are we there yet?

Now that you know the scope, you can look up the according CSV file, that is the one that is defined in this module's config.xml. It could also be more than one, but the generally followed convention is to have one file per module in the form Module_Name.csv.

  1. If this file does contains the string to be translated, you found it, except if you have a translate.csv in your theme, that overrides the translation for this exact scope (like: "Module_Name::Foo","Foo").

  2. If it's not in both, look for the translation without module scope prefix in translate.csv (if it exists).

  3. If it's not there, search in all other module CSV files. The one from the module that is loaded first, wins (i.e. core modules first, then alphabetically, respecting dependencies). Note that this fallback only is used when not in developer mode.


If you want to be sure, from which files a specific translation on the page is coming from, I can recommend you the free extension TranslationHints (DISCLAIMER: I wrote it)

Get it here: https://github.com/schmengler/TranslationHints

Screenshot: Translation Hints


Unless you're unit testing, you usually don't really care which translation csv is being used because they all get merged before Magento begins translation of anything.

However if you still want to figure it out, first use the layout xml files to figure out what block class is being used. If you find the block class, then it will use the config.xml of that module. If no block class is specified in the layouts you might need to go looking in the parent block classes and controllers.

The main thing to know is that the templates use the __ translation function of their associated block class, and the block class uses its module Data.php helper class's __ function.