Is soldering wires directly on a NiMh battery safe?
It's probably safe enough from your point of view, but not from the battery's. You really shouldn't solder to batteries unless they explicitly have solder tabs for that purpose. Most batteries, and NiMH are no exception, are damaged by soldering temperatures.
The way to make a permanent connection to a battery that doesn't have solder tabs is to use spot welding. This presses the battery terminal and the contact together, then zaps them by discharging a capacitor thru this connection. That heats the two parts enough for a little metal to melt and bond. However, the zap is very short and localized, so the total energy is low and high temperatures diffuse well before they get to sensitive parts of the battery.
Note that no solder is evident in the picture you show. That is because the tabs were spot welded, not soldered.
An important concept, when talking about spot welding batteries, is to realize that the welding electrodes used are arranged close together and applied to the top of the tab.
This ensures that the welding current flow is very localized at the "head" or "foot" of the battery, only through the tab and the relevant battery terminal cap The welding current does NOT pass "through" the battery at all, from one battery electrode to the other, but ONLY along the very short, closely-spaced spot-weld/solder tab.
The net result on the battery electrodes is no effect, and no electrical current flows through the battery at all during welding, only through the millimetre-or-two separated spot-weld area of the two pieces-to-be-welded.
I have terrible nightmares of people reading thread like this for the first time, grabbing using 2 large crocodile clips and passing 300 Amperes though a tiny AAA cell from one end to the other. This would be extremely dangerous, so I think should be mentioned because I've seen it attempted before, with disastrous results.
While I'd hesistate to say something was 100% safe I'd consider the risks with such large batteries as minimal to zero if you use a good technique. The way I'd go about it to minimise the risk with those batteries is:
- Under the tab you're about to solder place something like a steel ruler or other small piece of metal so that the tab isn't in direct contact with the battery while you solder. I see you've updated the photo with a new configuration that doesn't allow this so you may skip this step.
- Use a small file to give the tab a good clean and remove any outer protective coating that may have been applied and any oxidation.
- Using a solder that includes a flux core with your iron set to a slightly higher temperature than you might normally use on a PCB and you should be able to form a good joint within a few seconds.
After doing that you should find the body of the battery has only been heated enough to be barely detectable with your fingers if at all. For most NiMH batteries 60C is considered OK during charging (as a maximum) so unless it feels quite warm you'll be well under that limit.